Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.


Metamod and PHP code

Metamod and PHP code


I am trying to make this code working, but looks something is wrong.

$db =& JFactory::getDBO();
$userdb =& JFactory::getUser();
$user_id = $db->getEscaped((int)($userdb->id));
if ($user_id > 0) {
$query = "select cb_role from #__comprofiler where user_id = '$user_id';
$db->setQuery( $query );
$row = $db->loadObject();
$role = $row->cb_role;
if ($role == "Teacher") {return 80}
else if ($role == "Parent") {return 81;}
else if ($role == "Student")  {return 79;}
else if ($role == "Admin")  {return 130;}

I have made a few menus and a few copies of 'mod_mainmenu' (Menu IDs 79,80,81,130). I selected appropriate menu in each of the module and published them all in a same position 'menu'. Now, I created a module with 'mod_metamod' and put the above code and published this module on position 'menu'.

Now, as per PHP code, when user logs in, appropriate menu should be published on 'menu' position. But somehow its not working. I even tried to put a 'die' statement in my PHP code to test, if the PHP code is being executed by 'mod_metamod', but looks its not executing the PHP code.

I am not sure, what wrong I am doing ? Please help.

I will also appreciate, if you can point me to a good user manual on mod_metamod setup.

Kind Regards and thanks in advance.

Beginner Modder
1 Posts
Administrator has disabled public posting

Re: Metamod and PHP code

Hi Sandy,

Please follow the instructions in the QuickStart guide carefully:


The key things are:
1 - the metamod has to be published and set to the module position where you want the other modules (the "target modules") to appear
2 - the target modules need to be set up so that they don't appear unless/until the MetaMod includes them. e.g. unpublish them, or set them to a module position that doesn't actually get used on your template, or set them to display on "none" module positions.

Also don't forget MetaMod's debug mode. It can tell you a lot about what's going on. If you don't see any output from that, then the MetaMod isn't published, or isn't set to display on the page that you are currently viewing.

Hope that helps,

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

3330 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
Posts this week:
User Info:
Total Users:
Newest User:
Members Online:
Guests Online:

There are no members online

Forum Legend:

 New Sticky