Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts

    Need to alter a small piece of code to check for Categories in Joomla

    Hello I have a piece of code in my frontpage/default_item.php file which enables the category called 'Movies' to be given extra divs for CSS rounded corners.

    The code works fine and is as follows -
    PHP Code:
    <?php if($this->item->category == "Movies") { ?>
        <div><div><div>
    <?php ?>
    I would now like to add a second category to use rounded corners as well. The category will be called "Football".

    What do I need to add so the code to checks for more than one category e.g. both "Movies" & "Football"? I tried changing the code to the code below, but I get an error message
    Quote:
    Parse error: syntax error, unexpected ',' in....
    -
    PHP Code:
    <?php if($this->item->category == "Movies""Football") { ?>
        <div><div><div>
    <?php ?>
    Many thanks

    Tom

  2. #2
    Supreme Master coder!
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    10,172
    Thanks
    10
    Thanked 1,166 Times in 1,157 Posts
    This is an "OR" condition ... one or the other.

    PHP Code:
    <?php if($this->item->category == "Movies" || $this->item->category == "Football") { ?> 
        <div><div><div> 
    <?php ?>
    It couldn't be "AND" because it could never be both at the same time.

    Describe the logic on how it "should work".


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •