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.

 

Need some PHP syntax help

Need some PHP syntax help

Hello,

This is a fabulous module!  Thanks for making it available.

Joomla version 1.5, Metamod V2.6, website: www.eyetec.net

My problem:  I want to display a module (30) and control the cb login module based upon the state that my logged in user resides in.

The following php works to display the module based on the user residing in "kansas" or "ks".

$user_id = $db->getEscaped((int)($user->id));

if ($user_id > 0) {
$query = "select * from #__comprofiler  where user_id = '$user_id';";
$db->setQuery( $query );
$row     = $db->loadObject();
/* you can now get hold of state, phone, fax, website,
  * location, or whatever else they enter. All optional fields
  * like this get prefixed with "cb_" (see below).
  */

$state   = strtolower($row->state);
// etc... add more variables depending on what fields are set up in CB.

// your rules: use any of the following and customise as required.
if ($state == "ks" || $state == "kansas") return 30; /* check state */

}

In addition I want to present a logout post text message on the cb login module, conditional on the user residing in the state.  I think the php would look something like this, only I want to combine this with the php listed above, conditional on the state variable. My cb login module is #56.

$changes->mod(56)
   ->logoutposttext("message")
   
return 56;

}

Thanks for your help!!

eyetec
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Need some PHP syntax help

Hi,

Try this:

$user_id = $db->getEscaped((int)($user->id));
if ($user_id > 0) {
  $query = "select * from #__comprofiler  where user_id = '$user_id';";
  $db->setQuery( $query );
  $row     = $db->loadObject();
  /* you can now get hold of state, phone, fax, website,
   * location, or whatever else they enter. All optional fields
   * like this get prefixed with "cb_" (see below).
   */

  $state   = strtolower($row->state);

  // your rules: use any of the following and customise as required.
  if ($state == "ks" || $state == "kansas") {
    $changes->mod(56)
     ->setParam("logoutposttext","message");
    return 56;
  }
}


I think that should work...

Best regards,
Stephen

ps if you can't access the site right now it's because I'm changing my hosting. It may take another 24 hours for the DNS to propagate. Check back soon.

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

Board Info

Board Stats:
 
Total Topics:
1675
Total Polls:
6
Total Posts:
5917
Total Posts Today:
1
User Info:
 
Total Users:
11558
Newest User:
pitbull911
Members Online:
4
Guests Online:
229


Forum Legend:

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