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.

 

user logged in / logged out. syntax issue possibly.

user logged in / logged out. syntax issue possibly.

Hi Folks,

I've been using the category check along side a logged in / logged out status to switch between three different modules. I think I've just made a mistake with my syntax. Could anyone help me out please?

The code is as below:

Code:

$category_id = null;

if ( $option == "com_content" ) {
  if ( $view == "category" ) {
   /* category list pages (blog or list style) */
   $category_id = (int)$id;
  } else if (array_key_exists("catid",$_REQUEST)) {
   /* if the category id is in the URL */
   $category_id = (int)JRequest::getInt("catid",0);
  }
  if ( $category_id === null && $view == "article" ) {
   /* if it's an article page without the catid mentioned in the url */
   $nullDate = $db->Quote( $db->getNullDate() );
   $my_id = $db->Quote( $db->getEscaped( (int)$id ) );
   $jnow  =& JFactory::getDate();
   $now    = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );
   $query = "SELECT  title,  id,  catid "
       . " FROM #__content WHERE id = $my_id AND state = 1"
       . " AND ( publish_up = $nullDate "
       . " OR publish_up <= $now )"
       . " AND ( publish_down = $nullDate "
       . " OR publish_down >= $now  )";
   $db->setQuery( $query, 0, 1 );
   $row = $db->loadObject();
   $category_id = $row->catid;
  }
}
/* Now customise any of the following rules for your use.
* $category_id will correspond to the category id of the
* article being displayed (if one is being displayed!)
*/
if (($category_id == 41) & MM_LOGGED_IN ) return 80;
if (($category_id == 42) & MM_LOGGED_IN ) return 80;
if (($category_id == 43) & MM_LOGGED_IN ) return 80;
if (($category_id == 44) & MM_LOGGED_IN ) return 80;
if (($category_id == 45) & MM_LOGGED_IN ) return 80;
if (($category_id == 41) & MM_NOT_LOGGED_IN ) return 76;
if (($category_id == 42) & MM_NOT_LOGGED_IN ) return 76;
if (($category_id == 43) & MM_NOT_LOGGED_IN ) return 76;
if (($category_id == 44) & MM_NOT_LOGGED_IN ) return 76;
if (($category_id == 45) & MM_NOT_LOGGED_IN ) return 76;
else return 36;

If it my && MM_NOT_LOGGED in line at the end? The first part is copied and pasted and tested on its own. It worked alright. I should put these in arrays too, but im not sure.. erk.

Thanks alot in advanced for all your support.

Regards,

Ty

lordbarron
Guest
useravatar
Offline
Administrator has disabled public posting

Re: user logged in / logged out. syntax issue possibly.

Hi Ty,

I'm not sure, but the problem might be the use of "&". A single "&" by itself has a slightly different meaning to a double "&&" which is the right one to use.

Also valid (and my preferred method) is to use the word "and".

e.g.

if (($category_id == 41) and MM_LOGGED_IN ) return 80;

Try using that instead, and see if it works any 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

Re: user logged in / logged out. syntax issue possibly.

Hey thank you, that and a couple of other tweaks fixed my issues
I hadn't closed my brackets either.

Thank you once again for your continued support.

lordbarron
Guest
useravatar
Offline
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:
10152
Newest User:
kasautiizindagiikay
Members Online:
0
Guests Online:
378

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