Control modules on JReview pages

E-mail
(1 vote, average 5.00 out of 5)

In this example, we return different modules depending on whether jReviews is on its “base” page or looking at a “category”. We can choose the modules according to category as seen below. Note that if you have SEO urls turned on, jReviews acts slightly differently to when they are not turned on, so the code below tests for both cases. It's not the most elegant way to handle it, but shows you how to handle the situation.

if ($option == "com_jreviews") {
 $url = preg_replace("#/$#",'', JRequest::getVar('url',''); 
 // Test if we are on the top level page, not in a section or category.
 // Don't forget to change the module number from 18 to seomthing
 // appropriate for your site - or remove it altogether.
 if ($url == "") return 18;
 $parts = explode("/",$url);
 $last_part = $parts[count($parts)-1];
 $last_part = preg_replace("#_.*$#","",$last_part);
 
 /* Here's where you need to customise the recipe for your own use.
  * For each pair of "case" statements, put in one version with words
  * separated by ":" and one separated by "-".
  * Then return the module ID appropriate for that particular jReview.
  */
 switch ($last_part) {
   case "jreviews-category-list": // seo off
   case "jreviews:category:list": // seo on
     return 38;
   case "the-community": // seo off
   case "the:community": // seo on
     return 47;
   case "the-project": // seo off
   case "the:project": // seo on
     return 19;
   // add more as appropriate...
 }
}