Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Help using "different module for...
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
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
Re: Help using "different module for each category blog layout" recipe
- Index
- » MetaMod
- » MetaMod General Support
- » Help using "different module for...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7633
- Newest User:
- mingle7855
- Members Online:
- 0
- Guests Online:
- 160
- 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