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.

 

Run php rule

Run php rule

Hello,

I installed Chameleon and Easysocial (by Stackideas). I'd like set a php rule (Sql query) to apply a specific template style when user has selected some field value in his easysocial profile, for example "Green". Here is the structure of the table #_social_fields_data :
id
field_id
uid (id of user in joomla table)
type
datakey
data
params
raw

Please note that user must be logged in too, so i've just checked "All logged in" in Users and Groups tab.
I tried to set php rule below in Chameleon and i checked "true" in Default PHP return value. But it does not work.

if $user->uid > 0) {
  $data = Green;
  $query = "select uid from #_social_fields_data" where field_id = 72 and data = $data;
  $db->setQuery( $query );
  $yes = $db->loadResult();
  if ($yes) return true;
}


Help please.

wins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Run php rule

Try this. I hope it will work - at least it fixes some syntax issues in your original code:

if ($user->id > 0) {
  $query = "select uid from #_" . "_social_fields_data where field_id = 72 and data = 'Green' and uid = " . (int)$user->id;
  $db->setQuery( $query );
  $yes = $db->loadResult();
  if ($yes) return true;
}

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

Re: Run php rule

Hi,

It works with Default PHP return value on False.

Thank u.

wins
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Run php rule

Ah yes, I forgot to mention that too smile

Glad it's working for you - this is a great use for Chameleon.

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

Board Info

Board Stats:
 
Total Topics:
1696
Total Polls:
6
Total Posts:
5941
Posts this week:
8
User Info:
 
Total Users:
5378
Newest User:
gary9131
Members Online:
0
Guests Online:
175

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