Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Trying to use MetaMod Pro and having...
Trying to use MetaMod Pro and having problem in switching top menus.
Trying to use MetaMod Pro and having problem in switching top menus.
Hi there, I have 3 types of users using third party component. They are clients,candidates,partners. Using MetaMod Pro i am trying to control top menu choice. If clients logs in clients top menu; If candidate logs in respective candidate top menu. The same for partners. If no one logged in General top menu. Here is code i am using to switch my top menus:
//top menu selector
if ( MM_NOT_LOGGED_IN ) return 1;
// get the user details
$user =& JFactory::getUser();
$myuid=$user->get('id');
// find out what type of user we have
$user_type='';
// see if a candidate record exists for this user
$query="select * from ".$dbprefix."RAM_candidates where userid='$myuid'";
$sth=mysql_query($query);
$num_rows = mysql_num_rows($sth);
if ($num_rows>0){$user_type='candidate';}
// see if a client record exists for this user
$query="select * from ".$dbprefix."RAM_clients where userid='$myuid'";
$sth=mysql_query($query);
$num_rows = mysql_num_rows($sth);
if ($num_rows>0) {$user_type='client';}
// see if a partner record exists for this user
$query="select * from ".$dbprefix."RAM_partners where userid='$myuid'";
$sth=mysql_query($query);
$num_rows = mysql_num_rows($sth);
if ($num_rows>0) {$user_type='partner';}
switch ($user_type) {
case "client":
return 97;
break;
case "candidate":
return 102;
break;
case "partner":
return 107;
break;
}
It does not work properly. I believe it is my problem some where in the code, but could not pinpoint it. I would greatly appreciate if some one could get me (I hope) out of the woods. With great respect,
and thanks
Boris
Re: Trying to use MetaMod Pro and having problem in switching top menus.
Hi Boris,
the first obvious thing here is that you haven't allocated a value to $dbprefix, and it looks like you might need this. Perhaps you just didn't include that in the code that you pasted here... but you'll need to make sure that the names of your tables match what you are calling here.
Secondly, you're accessing the database using plain mysql queries rather than going through the Joomla database object system. It's not obvious that your mysql statements will actually connect to the right database etc.
I would recommend that you take a look at some of the recipes on this site that access the database (e.g. this one and switch to this more Joomla-friendly way of doing database access.
The logic of your rules looks perfectly correct, I think it's probably the database access which is not working.
(oh and by the way you don't have to use these lines: $user =& JFactory::getUser(); $myuid=$user->get('id'); -- just use: $myuid = $user->id -- because the $user variable is pre-populated for you in MetaMod)
Hope that helps,
Stephen
Re: Trying to use MetaMod Pro and having problem in switching top menus.
Hi, I too have three types of users using third party software (ijoobi's jcommunity) and I would love to be able to do this very thing, but my php skills are non existent. Is there any chance you could help me to do this please?
Re: Trying to use MetaMod Pro and having problem in switching top menus.
Hi Julian,
I don't have access to JCommunity, but it sounds like you do... could you perhaps run an experiment to see if the answer to this is going to be easy?
Can you set up a new MetaMod on your site and put the following rule into it:
echo "User type is: " . $user->usertype . "<br />";
Then log in as the different user types and see what you get?
I'd be interested to know if this technique will give you the names of the different groups. If it does, then it will be easy to make rules based on this.
Cheers,
Stephen
Re: Trying to use MetaMod Pro and having problem in switching top menus.
Stephen you are such a star I can't even tell you! Thanks so much. I did this, it worked, and then I looked up the recipe and figured the rest out. You are the man! It's an amazing extension and joomla would be useless to me without it! And brilliant support and tutorials! A million Thanks!
Re: Trying to use MetaMod Pro and having problem in switching top menus.
Hi Julian, I'm delighted it was this easy! I think I'll put up a recipe based on this, just so we can get jCommunity mentioned on the site :-)
Can I assume that you're just using a rule something like this? if ($user->usertype == "My jCommunity custom usertype") return 101;
Best regards,
Stephen
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Trying to use MetaMod Pro and having...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7633
- Newest User:
- mingle7855
- Members Online:
- 0
- Guests Online:
- 87
- 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