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
- » How to Hide Mods on Category Page Only
How to Hide Mods on Category Page Only
How to Hide Mods on Category Page Only
Hi,
I apologize in advance as I'm sure this has been posted somewhere already but I can't find it:
I need to be able to hide a module on category pages such as this:
http://www.thecrystalcache.com/index.ph … p;Itemid=2
and:
http://www.thecrystalcache.com/home/geodes/16
But, I need the module to continue to appear on the browse and product pages within the categories:
http://www.thecrystalcache.com/home/aga … rldwide/28
http://www.thecrystalcache.com/home/aga … 4/120-2005
(I'm trying to hide the left column browsing menu on category display pages to make room for the category images.)
Here's the code I tried for the Jewelry category (id=8):
Code:
$vm = JomGenius("virtuemart"); // need this at the start of every rule
if ( $vm->check("pagetype not= shop.browse") ) {
$category_id = $vm->info( "category_id" );
/* when browsing a specific category on browse page (e.g. category 2) */
if ($category_id == "8") return 16;
/* when browsing any other category on browse page */
return ZZZ;
}
Thanks for any help!
Re: How to Hide Mods on Category Page Only
Hi ironlion37,
I'm afraid I'm getting slightly confused by the different page types for the examples that you gave. Can you help to identify which page is which type?
The most precise way of doing this in MetaMod is to make a MetaMod and assign it to all pages, containing the following PHP:
$vm = JomGenius("virtuemart");
echo "page type is: " . $vm->info("pagetype") . "<br/>";
Then take a look at each of those pages and take a note of which one is which. Then can you post these back again here in the forum, with the URL for each one and a reminder of which ones you want the module to appear on, and which ones not?
Thanks,
Stephen
Re: How to Hide Mods on Category Page Only
Thank you. The metamod with the identifier is now live in the copyright position at the bottom of all pages.
So to hopefully give a more precise example:
I want to hide the Browse our Store Menu module on this page:
http://www.thecrystalcache.com/index.ph … p;Itemid=2
page type is: shop.browse
But not on this page:
http://www.thecrystalcache.com/home/ama … jewelry/56
page type is: shop.browse
The relationship between those two pages is that the first is a top level virtuemart category and the second is a subcategory residing within the top level (jewelry > Amazonite Jewelry).
Since both have page type shop.browse, it would seem that excluding by category id would be the way to do it?
Re: How to Hide Mods on Category Page Only
Here's the advanced debug info:
I want to hide the module on this page:
http://www.thecrystalcache.com/home/jewelry/8
Code:
Page Identification
The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please click here.
if (
$option == 'com_virtuemart'
and JRequest::getVar('page') == 'shop.browse' /*!*/
and JRequest::getVar('category_id') == '8' /*!*/
and $Itemid == '2'
) return XXX; /* replace XXX with the module ID or position to display */
Note: lines starting with "and" and ending with /*!*/ contain rules that may be optional. You may wish to leave them out.
MetaMod debug info:
Module ID: 92
$option: com_virtuemart
$view:
$id:
$Itemid: 2
$timezone: Etc/GMT+7
$language: en-us
$language_code: en
$language_region: us
page type is: shop.browse
Including modules: None
And I want to show the module on this page:
http://www.thecrystalcache.com/home/ama … jewelry/56
Code:
Page Identification
The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please click here.
if (
$option == 'com_virtuemart'
and JRequest::getVar('page') == 'shop.browse' /*!*/
and JRequest::getVar('category_id') == '56' /*!*/
and $Itemid == '2'
) return XXX; /* replace XXX with the module ID or position to display */
Note: lines starting with "and" and ending with /*!*/ contain rules that may be optional. You may wish to leave them out.
MetaMod debug info:
Module ID: 92
$option: com_virtuemart
$view:
$id:
$Itemid: 2
$timezone: Etc/GMT+7
$language: en-us
$language_code: en
$language_region: us
page type is: shop.browse
Including modules: None
Re: How to Hide Mods on Category Page Only
Yes, looks like you'll need to deal with these by category. The JomGenius support for VM includes some checking for ancester categories, so you can probably use these to your advantage.
e.g. you can test for category_ids (all categories that a product is in) or ancestor_category_ids (all categories it is in, including the parent categories, all the way to the top).
So in your case, if a product has ancestor_category_ids including 8 but NOT category_ids including 8, then it must be a sublevel of category 8. So in that case you display the module on on the sublevels of category 8. Hope I got that right!
e.g.
$vm = JomGenius("virtuemart"); // need this at the start of every rule
if ( $vm->check("pagetype = shop.browse")
and $vm->check("ancestor_category_ids = 8")
and ! $vm->check("category_ids = 8")
) return XXX;
// replace XXX with the module id of the module you want to display
Hope that's what you're after,
Stephen
Re: How to Hide Mods on Category Page Only
Thanks Stephen. You did get it right, but the code doesn't seem to have the desired effect...
I'm in the process of transitioning this site to Joomla 2.5/VM 2 so I'm going to hold off on this for the moment and pick it up again once I have the site setup on the new platforms.
Thank you!
Re: How to Hide Mods on Category Page Only
Oh, the reason it didn't work is that the code I sent was 2.5-specific. The names of the pages are a little different on J2.5/1.5 so that could be the problem.
On J2.5, the name of the page isn't "shop.browse", it's "category" I think... shop.browse is a J1.5-only thing. You can get the definitive list of page types from http://www.metamodpro.com/jomgenius/parameters#vm2x, or if you are ever in doubt, then use the echo $vm->info("pagetype") thing from a couple of posts' ago to ensure you got the right one.
Cheers,
Stephen
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » How to Hide Mods on Category Page Only
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7628
- Newest User:
- horlogekorting34
- Members Online:
- 0
- Guests Online:
- 105
- 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