Jump to content

default_image call in image.php


uk_ging32

Recommended Posts

Hi All,

 

New to the forum, so apologies if this is a stupid question 

 

Am working on a store built in PHP and smarty templates for the first time and in image.php there is the following call to establish a default image -

 

if (!empty($image_out)) {

  header("Content-type: $image_type");

  echo $image_out;

} else {

  header("Content-type: image/gif");

  func_readfile($default_image, true);

}

 

And in config.php the $default_image is given a file.

 

For the store there are five main categories and want I want to do is setup a default image for those root level categories. And I am not doing v well!!

 

I have -

if (!empty($image_out)) {

  header("Content-type: $image_type");

  echo $image_out;

} else if($current_category.categoryid eq "6325")

  header("Content-type: image/gif");

  func_readfile($default_image6325, true);

} else {

  header("Content-type: image/gif");

  func_readfile($default_image, true);

}

 

with a new call added to config.php for $default_image6325.

 

But this is not working at all and has broken the call for the $default_image as well.

 

I thought if I just used an else if statement assigning the root categoryid for each it would call the relevant image? Can anyone offer me a pointer on my obviously crap PHP code!!

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/40206-default_image-call-in-imagephp/
Share on other sites

Firstly use the code tags :P

 

if (!empty($image_out)) {
   header("Content-type: $image_type");
   echo $image_out;
} else if($current_category.categoryid eq "6325")
   header("Content-type: image/gif");
   func_readfile($default_image6325, true);
} else {
   header("Content-type: image/gif");
   func_readfile($default_image, true);
}

 

The problems looks like $current_category.categoryid is not a valid variable name.

It would have to be either $current_category or $categoryid, or maybe even $current_category_id :) IF you are wanting to create a dynamic variable it would be ${"$ccurrent_category$categoryid"}.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.