Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.


EarlSwille
Beginner Modder
ranks
useravatar
User Info

"Show modules on all submenus of a menu item" not working properly

Hello, when using the recipe "Show modules on all submenus of a menu item" the following does not work:

Code:

$mappings = array(

  27=>19,
  27=>22,
  27=>76
);

/* You should not need to edit anything under here */
$menu = &JSite::getMenu();
if (empty($Itemid)) {
  $menuItem = &$menu->getActive();
} else {
  $menuItem = &$menu->getItem($Itemid);
}
$tree = $menuItem->tree;
$all_modules = array();
foreach ($tree as $value) {
if (array_key_exists($value, $mappings)) $all_modules[] = $mappings[$value];
}
return $all_modules;

When item 27 is active, only the last of the listed modules (in this case module with id 76) is shown, not all (19 & 22), as expected.
Using:

Code:

$mappings = array(

  27=>19,
  24=>22,
  15=>76
);

works fine.
Any idea?
Thanks,great module, Uwe.


Administrator has disabled public posting
metamodguy
useravatar
User Info

Re: "Show modules on all submenus of a menu item" not working properly

Hi Uwe,

In that case, do it like this:

$mappings = array(
  27=>"19, 22, 76"
);


Cheers,
Stephen


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

Administrator has disabled public posting
EarlSwille
Beginner Modder
ranks
useravatar
User Info

Re: "Show modules on all submenus of a menu item" not working properly

Hello Stephen,
thank you for your quick reply.

metamodguy wrote:

$mappings = array(
  27=>"19, 22, 76"
);
Unfortunately this only gives me the first module (id 19), not 22 & 76.
Any other idea?
Thank you,
Uwe.


Administrator has disabled public posting
metamodguy
useravatar
User Info

Re: "Show modules on all submenus of a menu item" not working properly

Oh, yes, now I look at that I can see why. Sorry I gave you wrong information.

Try this instead. It doesn't use the $mappings array any more, as it just checks for the exact value you asked for (27):

Code:

$menu = &JSite::getMenu();

if (empty($Itemid)) {
  $menuItem = &$menu->getActive();
} else {
  $menuItem = &$menu->getItem($Itemid);
}
$tree = $menuItem->tree;
foreach ($tree as $value) {
  if ($value == 27) {
    return "19,22,76";
  }
}


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

Administrator has disabled public posting

Board Info

Board Stats:   Total Users: 3076  Total Topics: 1195  Total Polls: 7  Total Posts: 4448  Posts this week: 18
User Info:   Newest User :  tao   Members Online: 1   Guests Online: 131
Online 
Jeff78
Topic
New
Locked
Topic
New
Locked
Sticky
Active
New/Active
Sticky
Active
New/Active
New/Closed
New Sticky
Closed/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky Active Locked
Active/Sticky
Sticky/Locked
Sticky/Active/Locked