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.

 

Show Module on Categories and on Each Product of those Categories

Show Module on Categories and on Each Product of those Categories

My goal is to show the same module for several categories and each product of those categories. Here's my code which only works for the categories and not when the products are being viewed.

$vm = JomGenius("virtuemart"); // need this at the start of every rule
if ( $vm->check("pagetype = category") ) {
  $category_id = $vm->info( "category_id" );
  /* when browsing a specific category on browse page (e.g. category 2) */
  if ($category_id == "14") return 138;
  if ($category_id == "15") return 138;
  if ($category_id == "16") return 138;
  if ($category_id == "53") return 138;
  if ($category_id == "54") return 138;
  if ($category_id == "55") return 138;
  if ($category_id == "56") return 138;
  if ($category_id == "57") return 138;
  if ($category_id == "58") return 138;
  if ($category_id == "59") return 138;

  /* when browsing any other category page */
  return ZZZ;
}

Your help is greatly appreciated.

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

Re: Show Module on Categories and on Each Product of those Categories

Hi Touchdowntech,

The crucial element here is the second line, which tests for category pages, and only proceeds if a category page is found. All you need to do is remove that test (and the closing parentheses), then it will apply to ANY page type that can detect a category id.

So try this:

$vm = JomGenius("virtuemart"); // need this at the start of every rule
$category_id = $vm->info( "category_id" );
if ($category_id = 0) return; // short-circuit if we're not on a page that produces a category id.

/* when browsing a specific category on browse page (e.g. category 2) */
if ($category_id == "14") return 138;
if ($category_id == "15") return 138;
if ($category_id == "16") return 138;
if ($category_id == "53") return 138;
if ($category_id == "54") return 138;
if ($category_id == "55") return 138;
if ($category_id == "56") return 138;
if ($category_id == "57") return 138;
if ($category_id == "58") return 138;
if ($category_id == "59") return 138;

/* when browsing any other category page */
return ZZZ; // replace ZZZ with a module id, or delete the line.


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
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1684
Total Polls:
6
Total Posts:
5940
Posts this week:
1
User Info:
 
Total Users:
5161
Newest User:
kbmgkey234q
Members Online:
0
Guests Online:
179

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