Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Help using "different module for each category blog layout" recipe

Help using "different module for each category blog layout" recipe

Hi, I just started using this great module and found out how to place a different module (same position) for each category blog layout on my site. This is the code I found on the forum and it works fine:

///////////////////////////////////
$category_id = null;

if ( $option == "com_content" ) {
  if ( $view == "category" ) {
   /* category list pages (blog or list style) */
   $category_id = (int)$id;
  } else if (array_key_exists("catid",$_REQUEST)) {
   /* if the category id is in the URL */
   $category_id = (int)JRequest::getInt("catid",0);
  }
  if ( $category_id === null && $view == "article" ) {
   /* if it's an article page without the catid mentioned in the url */
   $nullDate = $db->Quote( $db->getNullDate() );
   $my_id = $db->Quote( $db->getEscaped( (int)$id ) );
   $jnow  =& JFactory::getDate();
   $now    = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );
   $query = "SELECT  title,  id,  catid "
       . " FROM #__content WHERE id = $my_id AND state = 1"
       . " AND ( publish_up = $nullDate "
       . " OR publish_up <= $now )"
       . " AND ( publish_down = $nullDate "
       . " OR publish_down >= $now  )";
   $db->setQuery( $query, 0, 1 );
   $row = $db->loadObject();
   $category_id = $row->catid;
  }
} elseif ($option == "com_sefservicemap") {
return 47;
} else {
return 47;
}
/* Now customise any of the following rules for your use.
* $category_id will correspond to the category id of the
* article being displayed (if one is being displayed!)
*/

if ($category_id == 37) return 67;
if ($category_id == 38) return 68;
return 67; /* default if nothing else matches */

////////////////////////////


My question is how do I stop the module from showing on the subsequent article pages that are linked to their respective category blog layout page?

Thanks for your time and help!
-Chris

perseverance23
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Help using "different module for each category blog layout" recipe

Hi Chris,

you're saying that you don't want the module on the article pages, but only on the category (blog) pages? In that case, we can strip out much of that rule, and simplify the rest, like this:

Code:

if ( $option == "com_content" and $view == "category" ) { 

   /* category list pages (blog or list style) */
   $category_id = (int)$id;
   if ($category_id == 37) return 67;
   if ($category_id == 38) return 68;
   return 67; /* default for any categories not mentioned */

} elseif ($option == "com_sefservicemap") {
  return 47;
} else {
  return 47;
}

I think that will do what you want. The category part of the code will only trigger on the category list/blog pages, and you can set up the other alternatives as you have done above (e.g. for com_sefservicemap and any others).

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Re: Help using "different module for each category blog layout" recipe

Thanks Stephen. This code was exactly what I was looking for. Great product and support!

Thanks again,
Chris

perseverance23
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Help using "different module for each category blog layout" recipe

Thanks for reporting back; glad it's working for you.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
3
User Info:
 
Total Users:
4397
Newest User:
tull687318
Members Online:
0
Guests Online:
167

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked