Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » $option == 'com_content' and...
$option == 'com_content' and specified sections/categories
Re: $option == 'com_content' and specified sections/categories
Are you wanting the modules on the article pages, when the articles are in the specified categories/sections, or just on category/section list or blog pages?
Cheers,
Stephen
Re: $option == 'com_content' and specified sections/categories
hi Stephen,
Thanks for your reply and sorry for the confusion. What I meant was I wanted modules on articles pages, and only to those which are specified categories/sections.
Say I have 5 categories and 5 sections. I would only want to restrict to one of the categories (say category named "directory"). I would only want my modules to appear on that category and that alone.
Maybe some other modules on the other 4, but you get me
I have seen something here: http://www.metamodpro.com/metamod/recip … e-category
but pardon my noobness, I am no coder so i really couldnt digest that. However, I think restricting modules for article pages within restricted categories/sections, wouldn't be something like in the recipe, right?
Thats way over my head!
Thanks again. Please advise.
Re: $option == 'com_content' and specified sections/categories
Hi,
you got the right recipe page. Yes, the recipe on there is kind of big, but the part you need to customise is at the bottom. All the top part is simply getting hold of the category id out of the article that's being displayed.
Here's a slightly simplified version that restricts the module display to ONLY article pages. Just customise the "if" statements at the bottom:
Code:
$category_id = null;
if ( $option == "com_content" and $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 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;
/* 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 == 1) return 55;/* on category 1, return module 55 */
if ($category_id == 2) return 56;/* on category 2, return module 56 */
if ($category_id == 3) return 57;/* on category 3, return module 57 */
return 50; /* default if nothing else matches */
}
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » $option == 'com_content' and...
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 2
- User Info:
- Total Users:
- 8026
- Newest User:
- rivas48750
- Members Online:
- 1
- Guests Online:
- 142
- Online:
- rivas48750
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked