Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2008
    Posts
    24
    Plugin Contributions
    0

    Default if no additional images do this, else do this

    Hi Guys :)

    I'm wondering is there a way to write an if statement something alongs the lines of

    PHP Code:
    if (noadditionalimages == true) {

    echo 
    'no additional images';

    } else {

    echo 
    'there are additional images';


    so basically if there are no additional images it outputs one thing, and if there are it outputs another

    Cheers!

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: if no additional images do this, else do this

    Quote Originally Posted by sephiroth View Post
    Hi Guys :)

    I'm wondering is there a way to write an if statement something alongs the lines of

    PHP Code:
    if (noadditionalimages == true) {

    echo 
    'no additional images';

    } else {

    echo 
    'there are additional images';


    so basically if there are no additional images it outputs one thing, and if there are it outputs another

    Cheers!
    What's wrong with the statement you have written? ok, so the "noadditionalimages" needs to be predefined, or passed as a variable for this to work with PHP, but other than that it seems ok.

    You could also use something like

    $message = ($noadditionalimages) ? 'no additional images': 'there are additional images';

    echo $message ;

    Somehow I don't thing this is what you are asking though.

    Perhaps you are wondering how to determine whether an additional image exists or not? or is it the logic, or perhaps just the syntax you are having difficulties with?

    Cheers
    Rod

  3. #3
    Join Date
    Nov 2008
    Posts
    24
    Plugin Contributions
    0

    Default Re: if no additional images do this, else do this

    yes, I'm looking for how to determine if there are additional images...

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: if no additional images do this, else do this

    Using the templates and overrides ... you could customize the file:
    tpl_modules_additional_images.php

    where it tests for if the number of additional images is greater than 0, then it displays them ... add an ELSE to the IF and you can customize it to output whatever you want ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: if no additional images do this, else do this

    Quote Originally Posted by sephiroth View Post
    yes, I'm looking for how to determine if there are additional images...
    Linda has already advised you in regards where you'll need to do your customisations (no sensible person would argue with her)

    You will probably find it convenient to use one of zen-carts own functions to perform the actual 'does it exist' check.

    The function (located in /functions/general.php) which you should NOT edit. is:

    function zen_info_image($image, $alt, $width = '', $height = '')

    This is the full function
    Code:
     function zen_info_image($image, $alt, $width = '', $height = '') {
        if (zen_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
          $image = zen_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
        } else {
          $image = TEXT_IMAGE_NONEXISTENT;
        }
    
        return $image;
      }
    Hope you find this useful.

    Cheers
    Rod

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: if no additional images do this, else do this

    Actually, you do not have to test for anything ... the template has the test with:
    Code:
     if ($flag_show_product_info_additional_images != 0 && $num_images > 0) {
    Just add the ELSE to that IF and what you want to do ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: if no additional images do this, else do this

    Quote Originally Posted by Ajeh View Post
    Actually, you do not have to test for anything ... the template has the test with:
    Code:
     if ($flag_show_product_info_additional_images != 0 && $num_images > 0) {
    Just add the ELSE to that IF and what you want to do ...


    As someone told me recently, sometimes the most obvious is the best.

    Cheers
    Rod

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: if no additional images do this, else do this

    I just like to peek ahead to see how hard things might be ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  9. #9
    Join Date
    Nov 2008
    Posts
    24
    Plugin Contributions
    0

    Default Re: if no additional images do this, else do this

    Thanks guys! will give it a go and let you know how i get on!

 

 

Similar Threads

  1. v139h Additional Images Layout on Product Pages - where can this be changed?
    By shags38 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 17 Aug 2012, 09:39 PM
  2. Hwo to I make this look like this IMAGES?
    By store.lakewood in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 10 Aug 2011, 07:31 PM
  3. Is this a database issue? Additional image-handler images not showing
    By crabdance in forum All Other Contributions/Addons
    Replies: 16
    Last Post: 14 Oct 2009, 12:28 AM
  4. if main display this else display this
    By poosk in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 21 Apr 2009, 02:04 PM
  5. Additional images... should they work like this?
    By Alex Clarke in forum General Questions
    Replies: 2
    Last Post: 23 Oct 2008, 12:36 PM

Posting Permissions

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