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 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

TaV
Beginner Modder
ranks
useravatar
Offline
2 Posts
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;

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

Re: Show module unless the others are enabled

I don't know what did you changed but I had already tried the "" in the $moduleid... lol

Thanks a lot.

TaV
Beginner Modder
ranks
useravatar
Offline
2 Posts
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

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

Board Info

Board Stats:
 
Total Topics:
1674
Total Polls:
6
Total Posts:
5917
Total Posts Today:
5
User Info:
 
Total Users:
11540
Newest User:
caron5112
Members Online:
0
Guests Online:
204

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