Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » IF IF ELSE
Page:
1
IF IF ELSE
IF IF ELSE
I have been adding to this script for a while and i am wondeirng how i could add a else if to the end of it so that all other scenarios for ""$option == 'com_virtuemart' and $Itemid == '81'"" get item ID 101 returned.
So what options do i have to make this script a bit better structored and also achive the else option.
Ww
Code:
if (
$option == 'com_virtuemart'
and $Itemid == '81'
and JRequest::getVar('category_id') == 13
) return 185;
if (
$option == 'com_virtuemart'
and $Itemid == '81'
and JRequest::getVar('category_id') == 14
) return 187;
if (
$option == 'com_virtuemart'
and $Itemid == '81'
and JRequest::getVar('category_id') == 29
) return 188;
Edited By: wildwill
16-Jun-10 23:56:27
16-Jun-10 23:56:27
Administrator has disabled public posting
Re: IF IF ELSE
Hi Will,
For a start, here's a way to structure what you already have:
Code:
if ( $option == 'com_virtuemart' and $Itemid == '81' ) {
$category_id = JRequest::getVar('category_id');
if ( $category_id == 13) return 185;
if ( $category_id == 14) return 187;
if ( $category_id == 29) return 188;
}
Then, just add your "else" to the end of that list. You already know that you have com_virtuemart and Itemid 81, so that will catch all the other categories and pages within that Itemid:
Code:
if ( $option == 'com_virtuemart' and $Itemid == '81' ) {
$category_id = JRequest::getVar('category_id');
if ( $category_id == 13) return 185;
if ( $category_id == 14) return 187;
if ( $category_id == 29) return 188;
return 101; // it doesn't even need the "else" in front of it
}
Administrator has disabled public posting
Page:
1
- Index
- » MetaMod
- » MetaMod General Support
- » IF IF ELSE
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Posts this week:
- 2
- User Info:
- Total Users:
- 7642
- Newest User:
- mary26
- Members Online:
- 0
- Guests Online:
- 144
- 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