Joomla Module that displays content based on visitors location?

Discussion in 'Joomla' started by awd, Jan 24, 2011.

  1. #1
    Hello DP'ers,

    I was wondering if there is a Joomla module that let's you display the pulled RSS news based on users IP or Facebook Location (using the facebook connect to login without registering) or based on the location that they select when they register ? since I have a news websites that pulls the news from a bunch of other national news sites and would like to display to the user only the news from their local news papers instead of all national news.

    Thanks.
     
    awd, Jan 24, 2011 IP
  2. buzzki

    buzzki Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    I wrote a module that can do this based on GeoIP location. At this time I don't know how you could hook it up to FB user location, but I would assume it's possible for anyone with enough knowledge of the FB API. The module is called MetaMod and you can get it from http://www.metamodpro.com

    Essentially MetaMod allows you to use a snippet of PHP to determine which module is going to get included in that position on the page. The GeoIP support allows you to check a variable called $fromCountryId which contains the upper case 2-letter country code of the visitor.

    What people generally do is to set up a handful of RSS feed modules, one for each country that you want to target, and take a note of the module IDs.

    Then you set up a MetaMod, and enter PHP into the MetaMod PHP box, something like the following:

    switch ( $fromCountryId ) {
      case 'US': return 101; // module 101 for USA
      case 'CA': return 102; // module 102 for Canada
      case 'GB': return 103; // module 103 for United Kingdom
    }
    Code (markup):
    Ok, so if you have a lot of different feeds for different countries, then setting up multiple RSS feeds, 1 per module, can still be unmanageable.
    MetaMod provides another feature called Module Parameter Control ( http://www.metamodpro.com/metamod/control-module-parameters ) which can help you with this. What it does is allows you to use MetaMod to dynamically change any of the module parameters that you would normally have to set using the normal module manager.

    Typically, RSS modules would have a text field where you type in the feed URL. Let's say that this parameter is known internally as "feed_url".

    In MetaMod you could then set up just 1 RSS module, just the way you like it. Then, modify the PHP above like this:

    $target_module = 101; // the module id of your RSS module; change as appropriate
    $url = "";
    switch ( $fromCountryId ) {
      case 'US': $url = 'http://my.feed.url/for_usa.xml'; break;
      case 'CA': $url = 'http://my.feed.url/for_canada.xml'; break;
      case 'GB': $url = 'http://my.feed.url/for_uk.xml'; break;
    }
    if ( $url ) {
      $changes->mod( $target_module )->setParam( 'feed_url', $url ); // change the URL in the target module, for this page only
      return $target_module; // tell the module to display
    }
    Code (markup):
    I think this is a very elegant way to achieve what you want to achieve. It doesn't require you to make any changes to the coding of your RSS feed module, and essentially gives you GeoIP capabilities for RSS or any other kind of module you want to control. I've personally helped one person to do *exactly* what I outlined above with RSS feeds, and I know there are countless more doing similar things with other modules.

    Cheers,
    Stephen
     
    buzzki, Jan 24, 2011 IP