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 a module on every page where another module is

Show a module on every page where another module is

Hi,


I'm new here and don't understand PHP. I was wondering what do I have to change in the following recipe so a module will apear on every page another module is also.

Show a module on every page that another module does not appear

Code:

$moduleid = 23; /* 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 101;

Thanks in advence,

Laurens_Cleyman
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Show a module on every page where another module is

Hi Laurens,

Try this:

Code:

$moduleid = 23; /* 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();
$there = $row != null and $row->c > 0;

/* replace XXX with module id to display when the other module is assigned to this page */
if ($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
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10789
Newest User:
parus6
Members Online:
1
Guests Online:
184

Online: 
parus6

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked