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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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