Plugin

Developer
Supported

Field Value

ExpressionEngine 1.x, ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Laisvunas

     

You must be logged in to post.

Using “if” with field_value

Support Request

Chris Arnold
Chris Arnold

I’m back on the same project built with child categories and field value. We’re in need of creating an optional tag or badge inside this child categories loop. In essence I have a field (P&T Switch) that needs to be rendered IF chosen.

If so-and-so, then display this <span> tag. I’m finding that the following code doesn’t do anything. Can field value render this? Perhaps I have the syntax incorrect.

{if "field_value_product-availability" == "n"}
<span>Out of stock!</span>
{/if} 
Chris Arnold
# 1
Chris Arnold

So, a couple things! I was still on v1.4 which I finally realized did NOT support conditionals. So I flipped over to v1.6 but this broke the site. I was seeing errors like this: http://cl.ly/image/2i3i3z0Y2b0A

I compared the differences in the files and pulled over the $tagdata and $conds lines, which may be a little hacky, yes, but it worked. I’m not sure why the full 1.6 did not, however, so feel free to reference that in your response.

Laisvunas
# 2
Developer
Laisvunas

Hi Chris,

Your conditional should be as this:

{if field_value_product-availability == "n"}
<span>Out of stock!</span>
{/if} 
Chris Arnold
# 3
Chris Arnold

Yeah, got that. Read my second post…