Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Hide a module based on two if...
Hide a module based on two if statements?
Hide a module based on two if statements?
Since I'm not familiar with PHP I'm kind of lost. I've looked through the available recipes, but haven't been able to make anything useful to accomplish my need.
I initially had my main login module only visible on pages where the usertype was "Public Frontend". That worked fine. Now I have a second login module on a page that will only be accessible from a link I send in an email. It's a different login module because this particular one will redirect to a specific page.
The problem is on the special page it shows both login modules.. I first thought I could just combine the page id detection to not show the default login module on the page id that the special login module appears, but in my efforts I haven't been successful. I tried using or statements among other things, but I'm sure I'm just doing it wrong.
The two separate pieces of code I have been trying to combine are below. Any help or direction would be appreciated. Thanks.
Code:
if ($user->usertype == "" || $user->usertype == "Registered") return 116;
if ( !(
$option == 'com_content'
and $view == 'article'
and $id == '102'
and $Itemid == 'null'
and JRequest::getVar('layout') == 'default' /*!*/
)) return 116;
Re: Hide a module based on two if statements?
So I ended up figuring out one way of doing it. Accidental I'm sure
Code:
if (!(( MM_LOGGED_IN ) || ($option == 'com_content'
and $view == 'article'
and $id == '102'
and $Itemid == 'null'
and JRequest::getVar('layout') == 'default'))) return 116;
This works. But if there is a better more correct way to be doing, I'm open. Thanks.
Re: Hide a module based on two if statements?
Hi Kevin,
The format of your rule is basically correct and should work fine. But just for the record I'll give you a slightly simpler rule that will do the same thing.
Code:
if (MM_NOT_LOGGED_IN
and !(
$option == 'com_content'
and $view == 'article'
and (int)$id == 102
)
) return 116;
The Itemid line wasn't necessary (and null should not be in quotes), and the layout parameter wan't necessary either. I took the integer value of the $id variable because under some circumstances the $id value can equal '102:title here', so it's a little safer to convert to an integer which strips off any other text after the digits.
Cheers,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Hide a module based on two if...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7638
- Newest User:
- moner86658
- Members Online:
- 0
- Guests Online:
- 151
- 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