masif2024 Posted July 20, 2016 Share Posted July 20, 2016 plz help how to add Different banner in each category? With if statement i want to add banner at top of category page i have here example of this kind and i also attached screen shots how i implment in prestashop in category.tpl file switch($_GET['id']) { case 1: $banner = '1.png'; break; case 2: $banner = '2.png'; break; case 3: $banner = '3.png'; break; case 4: $banner = '4.png'; break; case 5: $banner = '5.png'; break; } $image = <<<EOF <img src="$banner "/> EOF; echo $image; Link to comment Share on other sites More sharing options...
masif2024 Posted July 20, 2016 Author Share Posted July 20, 2016 i need help plz anybody do it Link to comment Share on other sites More sharing options...
masif2024 Posted July 20, 2016 Author Share Posted July 20, 2016 plz help how to add Different banner in each category? With if statement i want to add banner at top of category page i have here example of this kind and i also attached screen shots how i implment in prestashop in category.tpl file switch($_GET['id']) { case 1: $banner = '1.png'; break; case 2: $banner = '2.png'; break; case 3: $banner = '3.png'; break; case 4: $banner = '4.png'; break; case 5: $banner = '5.png'; break; } $image = <<<EOF <img src="$banner "/> EOF; echo $image; Link to comment Share on other sites More sharing options...
rocky Posted July 21, 2016 Share Posted July 21, 2016 Try something like: {if isset($smarty.get.id) && $smarty.get.id|intval >= 1 && $smarty.get.id|intval <= 5} <img src="{$img_dir}banners/{$smarty.get.id|intval}.png" width="1755" height="245" alt="" /> {/if} Change the image width and height as required. You can then create a themes/<your_theme>/img/banners subdirectory and put the banners in there. Link to comment Share on other sites More sharing options...
vekia Posted July 21, 2016 Share Posted July 21, 2016 plz help how to add Different banner in each category? With if statement i want to add banner at top of category page i have here example of this kind and i also attached screen shots how i implment in prestashop in category.tpl file switch($_GET['id']) { case 1: $banner = '1.png'; break; case 2: $banner = '2.png'; break; case 3: $banner = '3.png'; break; case 4: $banner = '4.png'; break; case 5: $banner = '5.png'; break; } $image = <<<EOF <img src="$banner "/> EOF; echo $image; the code you attached is a php code. you cant use php in .tpl files, so in this case it will be much better to transform code to smarty and instead of switch - use if / elseif conditions <img src="{if $smarty.get.id_cat==1}1.png{elseif $category->id==2}2.png{elseif $category->id==3}3.png{elseif $category->id==15}15.png{/if}"/> with if condition you can handle much more id numbers, not only numbers between 1-5 as on example one reply above Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now