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.

 

VirtueMart Shopper Group

VirtueMart Shopper Group

I'm trying to show module 137 to a Shopper Group 7 and no module to all other groups. The code is as follows but it doesn't work...:

if ($user->usertype == "Registered") {
$id = (int)$user->id;
$query = "SELECT  shopper_group_id FROM #__vm_shopper_vendor_xref " .
   " WHERE user_id = '$id'";
$db->setQuery( $query, 0, 1 );
$row = $db->loadObject();
$groupid = $row->shopper_group_id;
if ($groupid == 7) return 137; /* for VM shopper group 7, use module 137 */
else return; /* for all other groups use no module */
}

Any suggestions:)??

mariuszstach
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Re: VirtueMart Shopper Group

Hi,

the basic code looks fine. A couple of things to check though:

1 - don't use the "jos_" prefix for database calls. Instead, prefix with "#__". Joomla is smart enough to convert that to the right prefix for your installation (remembering that when you install Joomla you should have set this to a unique prefix, right??)

Therefore:
$query = "SELECT  shopper_group_id FROM #__vm_shopper_vendor_xref " .
   " WHERE user_id = '$id'";

2 - if you're just searching for a specific group id, why not put that into the query? There are 2 reasons for this. One is that it makes the query more specific and hopefully quicker, and the second is that if the user is in more than 1 group, you should really loop through all the results to check all of them for the group you are checking for. If you restrict the results to only that group, then you don't need to do that.

Therefore:
$query = "SELECT  shopper_group_id FROM #__vm_shopper_vendor_xref " .
   " WHERE user_id = '$id' and shopper_group_id = 7 ";

Try that - it might make things work better.

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

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5910
Total Posts Today:
1
User Info:
 
Total Users:
10144
Newest User:
leonard5412396
Members Online:
2
Guests Online:
142


Forum Legend:

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