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.

 

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 22:56:27

wildwill
Beginner Modder
ranks
useravatar
Offline
2 Posts
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
}

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

Board Info

Board Stats:
 
Total Topics:
1680
Total Polls:
6
Total Posts:
5914
Total Posts Today:
1
User Info:
 
Total Users:
10831
Newest User:
bluesky1
Members Online:
0
Guests Online:
133

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