Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » problem with repcie and modul with...
problem with repcie and modul with split menu
problem with repcie and modul with split menu
Hi,
there is a problem with "Show a module on every page that another module does not appear" recpie and
a module with split menu. I have a module with split menu on left side position - ID 43. And I want to show module with ID 50 if there is no side menu. The repce does not work:
$moduleid = 43; /* the module with my side menu */
$sql = 'SELECT count(*) as c from #__modules m, #__modules_menu mm ' .
'WHERE mm.moduleid = m.id ' .
'and m.published = 1 ' .
'and (mm.menuid = ' .
(int)$Itemid . ' or mm.menuid = 0) and mm.moduleid = ' . (int)$moduleid;
$db->setQuery( $sql, 0, 1 );
$row = $db->loadObject();
$not_there = ($row == null or $row->c == 0);
/* replace 101 with module id to display when the other module is not assigned to this page */
if ($not_there) return 50;
Joomla version 1.5.15
Meta_mod verion 2.0BETA
URL: http://nowa.maszoperia.pl/
regards,
malin
Re: problem with repcie and modul with split menu
Hi Malin,
Can I ask how the split menu is assigned to the page? You say that it's a module... so are you assigning that module to certain menu items in the normal way?
If so, the recipe should work. Can you check a few things:
1 - if you turn MetaMod debug mode on, do you see some output on every page that the MetaMod is assigned to? (that's just to check that it's turned on, and in the right module position)
2 - is your target module, id 50, operational? if you assign that target module onto a page without MetaMod involved, does it show up?
3 - Do you see a difference in MetaMod debug output when you are on a page with the split menu assigned to it, and a page where the split menu is not assigned? e.g. the last line of the debug output is "Including modules: ". When it's going to include a module, it puts the ID number there. Do you ever see this?
It's quite possible that it's just a setup problem rather than a problem with the recipe. So let's make sure you've got the basics right first, then once you're sure those are ok we can check the recipe too.
Best regards,
Stephen
Re: problem with repcie and modul with split menu
p.s. the most recent version of MetaMod Pro is 2.1. See the instructions in http://www.metamodpro.com/metamod/download to update your version of MetaMod Pro.
MetaMod is up to version 2.2c as well, so you're a bit behind. I'd recommend that you upgrade both MetaMod and MetaMod Pro before doing further testing.
Stephen
Re: problem with repcie and modul with split menu
Hi metamodguy,
I have updated to 2.1 version.
My module with split menu is assigned to all pages, but it works in this way that is shows only when there is some menu item. When there is no menu item the module is empty.
Probably is solves the problem. There is an assigment in the database that's why the metamod module does not shows up.
Would it be possible to check if on current page there is a menu item with level 1 or higher ?
Kind regards,
malin
Re: problem with repcie and modul with split menu
Hi malin,
I see what you mean now. You want to test what menu and sublevel the current page is on, and if it's not a certain menu or sublevel, then the split menu is going to be empty, so you want to hide then entire split menu module.
Here's how to do that:
Code:
$menu = &JSite::getMenu();
$active = $menu->getActive();
if (@$active->menutype == 'mainmenu' and @$active->sublevel >= 1) return XXX; /* replace XXX with module id of splitmenu module */
You may need to tweak this a bit to get it working the way you want it - but the basic principle is there.
In the example above, it only shows the split menu if the "active" menu item is (1) on the "mainmenu" menu, and (2) is 1 or more levels deep. If it's on any other menu, or is at level 0 on the mainmenu, then the split menu won't show.
I think this will do what you want - can you report back and let me know if it worked for you?
Best regards,
Stephen
Re: problem with repcie and modul with split menu
Hey Stephen -
I need your wizardly advice. The solution above meets most of my needs - it just needs a tweak and I'm not seeing the menu-genius test that I need.
The tweak, "if sublevel >= 1 show split module" code above is fine, but need one more variation.
"if sublevel = 0 AND active menu item has children, show split module else show filler module.
I'm looking for how to check for children to wrap an if test around
$changes->mod(49)
->title($menu_genius->info( "title" ) . " - Sub-Menu:");
return 49;
MMP 3.6 on J 1.7.0
Re: problem with repcie and modul with split menu
Hi Duke,
that's a good question. There's no current "genius" check for whether the current item has children or not, so we'll need to code that direct into the rule.
You can get the list of children, and count them, this way:
$menu = &JSite::getMenu();
$items = $menu->getItems(array("parent_id"), array($Itemid));
$count = count($items);
There's also a change in Joomla 1.7 about the way that levels are calculated. The top level is now level 1 instead of level 0. And the parameter is called "level" instead of "sublevel".
Therefore, I'd code your rule like this for Joomla 1.7:
$menu = &JSite::getMenu();
$active = $menu->getItem($Itemid);
if (@$active->level == 1) {
$items = $menu->getItems(array("parent_id"), array($Itemid));
if (count($items) > 0) {
$changes->mod(49)
->title($menu_genius->info( "title" ) . " - Sub-Menu:");
return 49;
}
}
Hope that helps,
Stephen
p.s. If you use MetaMod, please post a rating and a review at the Joomla! Extensions Directory
Re: problem with repcie and modul with split menu
This worked nicely, thank you!
It was further enhanced as shown in this thread.
http://www.metamodpro.com/forums/topic?id=788
- Index
- » MetaMod
- » MetaMod General Support
- » problem with repcie and modul with...
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 2
- User Info:
- Total Users:
- 8021
- Newest User:
- shrutihassan193
- Members Online:
- 0
- Guests Online:
- 153
- 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