uk_ging32 Posted February 26, 2007 Share Posted February 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
mbtaylor Posted February 26, 2007 Share Posted February 26, 2007 Firstly use the code tags 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"}. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.