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 $db additional database

MetaMod $db additional database

My user register on Stack Ideas - Easy Social.
For my user I have made a custom address field. There, the user can select which module he wants to see. The Unique Key is "ADDRESS-1". And I've done my own database regions.
The data in SQL: "xxxxx_social_regions"

There has, for example, the code "module-paris" the id 5

In MetaMod PHP I have now entered the following:

if ($ option == "com_easysocial" and JRequest :: getVar ("region") == "module-Paris") return 117;
if ($ option == "com_easysocial" and JRequest :: getVar ("region") == "module-milano") return 110;
if ($ option == "com_easysocial" and JRequest :: getVar ("region") == "module-roma") return 117;

If now a registered user and thereby chooses that he wants to see Paris-module, module ID 117 does not appear.

What I have done wrong?

Thanks and best regards, Chris.

Beginner Modder
1 Posts
Administrator has disabled public posting

Re: MetaMod $db additional database

Hi Chris,

I think you may be getting a couple of different concept mixed up here. Let's try to get this sorted out.

1 - the JRequest::getVar("region") code retrieves a parameter from the URL of the page request, in one of 2 ways:
a - either the URL is like /index.php?region=module-paris
b - or with friendly SEF URLs turned on it may be something like /mypage/region/region-paris, and the SEF system assigns region=module-paris

2 - You gave a description of setting up a database table with some regions in it, that somehow ties in to an "Easy Social" database. Now, I don't know exactly how Easy Social does this but I found some docs:

Is it using this that you set up the regions?:
http://stackideas.com/docs/easysocial/a … tom-fields
Does it appear as a dropdown in the profile?

What I THINK you want to do (please correct me) is this:

- each logged in user has a region in their profile, set up using the mechanism above
- when that user is logged in, a module appears on each page, depending on the region in their profile.

To do this we will most likely need to make a database query that queries using the user_id. This will give the region name. Then we can use this in the "if" statements to pull in the appropriate module.

It will be something like this:

if ($user->id > 0 and $option == "com_easysocial") {
  $sql = "select blablabla.....  query here depending on database structure...  WHERE u.user_id = " . (int)$user->id;
  $region = $db->loadResult();
  if ($region == 'module-paris') return 117;
  if ($region == 'module-milano') return 110;
  if ($region == 'module-roma') return 117;

So the main thing to do will be to unravel the database structure so we can extract the region name from it.

But first, can you confirm that this is what you want? Then we can work on the database structure question.

Best regards,

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

3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

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


Forum Legend:

 New Sticky