Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / if no additional images do this, else do this

if no additional images do this, else do this

Views: 618

Results 1 to 9 of 9
31 Jul 2011, 1:40 PM
#1
sephiroth avatar

sephiroth

New Zenner

Join Date:
Nov 2008
Posts:
24
Plugin Contributions:
0

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

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! :D

31 Jul 2011, 1:53 PM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

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

sephiroth:

Hi Guys :)

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

if (noadditionalimages == true) {

echo 'no additional images';

} else {

echo 'there are additional images';

}

> 
> Cheers! :D

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
31 Jul 2011, 1:58 PM
#3
sephiroth avatar

sephiroth

New Zenner

Join Date:
Nov 2008
Posts:
24
Plugin Contributions:
0

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

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

31 Jul 2011, 2:06 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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 ...

31 Jul 2011, 3:07 PM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

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

sephiroth:

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

Linda has already advised you in regards where you'll need to do your customisations (no sensible person would argue with her) :D

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

 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

31 Jul 2011, 3:09 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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:

 if ($flag_show_product_info_additional_images != 0 && $num_images > 0) {

Just add the ELSE to that IF and what you want to do ... :smile:

31 Jul 2011, 3:24 PM
#7
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

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

Ajeh:

Actually, you do not have to test for anything ... the template has the test with:

if ($flag_show_product_info_additional_images != 0 && $num_images > 0) {


:blush::blush::blush::blush:

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

Cheers
Rod
31 Jul 2011, 3:35 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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

I just like to peek ahead to see how hard things might be ... :cool:

31 Jul 2011, 7:14 PM
#9
sephiroth avatar

sephiroth

New Zenner

Join Date:
Nov 2008
Posts:
24
Plugin Contributions:
0

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

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