Jump to content

Problem with smarty img condition


Recommended Posts

Hi guys,

 

I have to display different icons on different pages of my website and I had no problem to do that until today. Here is the problematic code :

<img {if $page_name eq 'module-ph_simpleblog-list' or $page_name eq 'module-ph_simpleblog-single'}src="/img/icone-panier-light.png"{elseif $cms->id eq '7' or $cms->id eq '8' or $cms->id eq '9' or $cms->id eq '10' or $cms->id eq '11' or $cms->id eq '13' or $cms->id eq '14' or $cms->id eq '15' or $cms->id eq '16' or $cms->id eq '17' or $cms->id eq '18' or $cms->id eq '19'}src="/img/icone-panier-black.png"{else}src="/img/icone-panier.png" width="31" height="20" alt=""/>{/if}

When I go to my frontoffice, all the CMS pages I indicated are displaying the icone-panier.png in place of icone-panier-black.png that I wanted to show.

 

Did I make a mistake somewhere? However I used that kind of condition in the header and it worked.

 

Please.

Thanks!

Edited by johanndc (see edit history)
Link to comment
Share on other sites

To me it seems like there is a conflict try to add $cms->id also to first if or make the second else, but this would cause no image to display if the $cms->id were not identified and the page was not 'module-ph_simpleblog-list' or 'module-ph_simpleblog-single

// This part checks for page but not $cms->id 

<img {if $page_name eq 'module-ph_simpleblog-list' or $page_name eq 'module-ph_simpleblog-single'}

src="/img/icone-panier-light.png"

//this part checks for $cms->id  only so both can be imitating at the same time 
{elseif $cms->id eq '7' or $cms->id eq '8' or $cms->id eq '9' or $cms->id eq '10' or $cms->id eq '11' or $cms->id eq '13' or $cms->id eq '14' or $cms->id eq '15' or $cms->id eq '16' or $cms->id eq '17' or $cms->id eq '18' or $cms->id eq '19'}


src="/img/icone-panier-black.png"{else}src="/img/icone-panier.png" width="31" height="20" alt=""/>{/if}

Does this make any sense its still displaying the one as if the pages are true and the $cms->id elseif is also true they will both initialize.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...