[SOLVED] Products module - show icons if selected option is 'true'

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

[SOLVED] Products module - show icons if selected option is 'true'

Post by ukmgranger »

Hi there,

I am using the products module to build a database of campsites that allow campfiers in the UK.  You can see it here:
http://www.campfires-allowed.co.uk

I have a set of custom fields set up as check boxes which I want to use to show an icon on the products page if it is set to true.

The code below shows what I have done for this, but it isn't working quite right.  Basically the code below shows the icon if there is ANY value in the checkbox - true or false.

How would I have it only display the icon when the value is 'true'?

Code: Select all

{if $entry->fields.CaravansAllowed->value}
<div class="icon">
<img src="uploads/images/iconCaravan.png" alt="Caravans Allowed" width="38" height="38" />
</div>
{/if}
Thanks in advance people.:)
Last edited by ukmgranger on Thu May 07, 2009 3:56 pm, edited 1 time in total.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Products module - show icons if selected option is 'true'

Post by jmcgin51 »

ukmgranger wrote: Hi there,

I am using the products module to build a database of campsites that allow campfiers in the UK.  You can see it here:
http://www.campfires-allowed.co.uk

I have a set of custom fields set up as check boxes which I want to use to show an icon on the products page if it is set to true.

The code below shows what I have done for this, but it isn't working quite right.  Basically the code below shows the icon if there is ANY value in the checkbox - true or false.

How would I have it only display the icon when the value is 'true'?

Code: Select all

{if $entry->fields.CaravansAllowed->value}
<div class="icon">
<img src="uploads/images/iconCaravan.png" alt="Caravans Allowed" width="38" height="38" />
</div>
{/if}
Thanks in advance people.:)
Just a guess (untested):

Code: Select all

{if $entry->fields.CaravansAllowed->value == "1"}
<div class="icon">
<img src="uploads/images/iconCaravan.png" alt="Caravans Allowed" width="38" height="38" />
</div>
{/if}
ukmgranger
Forum Members
Forum Members
Posts: 72
Joined: Wed Apr 04, 2007 9:54 am

Re: [SOLVED] Products module - show icons if selected option is 'true'

Post by ukmgranger »

Thanks jmcgin51! :)

Your solution was close enough - it is the syntax that I don't understand yet.  The solution for me was:

Code: Select all

{if $entry->fields.CaravansAllowed->value == "true"}
<div class="icon">
<img src="uploads/images/iconCaravan.png" alt="Caravans Allowed" width="38" height="38" />
</div>
{/if}
I just had to replace "1" for "true".

Thanks again
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: [SOLVED] Products module - show icons if selected option is 'true'

Post by jmcgin51 »

great!  I almost wrote "true", but decided you could probably substitute "1".  Now that I'm thinking about it, I think removing the quotes around the "1" would make it work that way.

Anyway, glad to help!
Post Reply

Return to “Modules/Add-Ons”