Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » user logged in / logged out. syntax...
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
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
- Index
- » MetaMod
- » MetaMod General Support
- » user logged in / logged out. syntax...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7623
- Newest User:
- laptopreviews21
- Members Online:
- 2
- Guests Online:
- 161
- Online:
- boestreecare, laptopreviews21
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked