Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Show module unless the others are...
Page:
1
Show module unless the others are enabled
Show module unless the others are enabled
I have 4 menus in my page. I want the main menu (1) to always show up unless the module 50, 51 OR 52 are enabled.
I found this receipt in the metamod site but I can't change it to check for multiple modules:
http://www.metamodpro.com/metamod/recipes/36-component-specific/93-show-where-specific-module-does-not-appear wrote:
Code:
$moduleid = 50; /* the module we are checking for. Customise this! */
$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 1;
Any ideas?
Thanks in advance
Administrator has disabled public posting
Re: Show module unless the others are enabled
Sure, try this:
Code:
$moduleid = "50, 51, 52"; /* the modules we are checking for. Customise this! */
$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 in (' . $moduleid . ')';
$db->setQuery( $sql, 0, 1 );
$row = $db->loadObject();
$not_there = ($row == null or $row->c == 0);
/* replace XXX with module id to display when the other module is not assigned to this page */
if ($not_there) return XXX;
Administrator has disabled public posting
Re: Show module unless the others are enabled
It was that line, plus one other important bit:
... and mm.moduleid in (' . $moduleid . ')';
In the SQL statement you can say "and mm.moduleid = 10", or you can say "and mm.moduleid in (10, 11, 12)" to see if it's in that set of numbers. So I changed to the latter form.
Cheers,
Stephen
Administrator has disabled public posting
Page:
1
- Index
- » MetaMod
- » MetaMod General Support
- » Show module unless the others are...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7638
- Newest User:
- moner86658
- 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