Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Condense code: else if's
Condense code: else if's
Condense code: else if's
This IS working but would like to condense it:
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '1'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '2'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '3'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '4'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '5'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '6'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '7'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '8'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '9'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else;
if (
$option == 'com_hotproperty'
and $view == 'types'
and $id == '10'
and $Itemid == '65'
and JRequest::getVar('layout') == 'properties'
) return;
else return 113;
I attempted and $id == "1,2,3,4,5,6,7,8,9,10'
didn't work...
Thank you!
Re: Condense code: else if's
Ok, how about this version:
if (
$option == 'com_hotproperty'
and $view == 'types'
and JRequest::getVar('layout') == 'properties'
) {
$exclusions = array(1,2,3,4,5,6,7,8,9,10);
if (in_array( $id, $exclusions )) return;
}
return 113;
Or, even simpler since you are using ids 1 to 10 consecutively:
if (
$option == 'com_hotproperty'
and $view == 'types'
and JRequest::getVar('layout') == 'properties'
and $id >= 1 and $id <= 10
) return;
return 113;
I deliberately left out the Itemid check, as that is equivalent to checking for the menu item. If you assign the MetaMod to only that menu item, then it's redundant in the PHP. If you assign the MetaMod to ALL menu items, then it might be useful to not check for the Itemid, so that the rule will catch the URLs even if the Itemid gets screwed up.
Hope that helps,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Condense code: else if's
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7624
- Newest User:
- borger3298
- Members Online:
- 0
- Guests Online:
- 166
- 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