0

I have a field named {the_shadow} set up with P&T Switch field type of "yes" and "no" for their values. For some reason it doesn't seem to work:

{exp:channel:entries 
    channel="portfolio_work"
    orderby="random"
    limit="20"
    disable="member_data|pagination|categories|categories_fields"
}
    {if main_photo}
    <!-- Work -->
        <li class="touchcarousel-item">          
            <div class="workPiece">{exp:gwcode_fileinfo:single file="{main_photo}"}<img src="{main_photo}" width="{image_width}" height="505" alt="{title}" />{/exp:gwcode_fileinfo:single}</div>
            {if the_shadow == "yes"}<div class="workShadow">&nbsp;</div>{/if}

    </li>
        {/if}
{/exp:channel:entries}  

I am running ee v.2.5.5.

Thanks, -Sam

1
  • Can you be a bit more specific about what doesn't work? What have you tried so far? For more details about what to include in your question, see our FAQ. Mar 11, 2013 at 15:31

1 Answer 1

1

Try something like this. You'll see that pt_switch actually outputs 'y' not 'yes'. :) If you're having trouble with conditionals. always echo out your variables so you can see what you need to test against. :)

    {exp:channel:entries channel="pt_test_channel"}
<h1>{title}</h1>
    {pt_switch}
    {if pt_switch == 'y'}
    yessirreebob
    {/if}

{/exp:channel:entries}

So in your case you need this line:

{if the_shadow == "y"}<div class="workShadow">&nbsp;</div>{/if}
2
  • Thanks, Lisa. I did a test above and it works. The weird thing is when it won't work when it's set to default yes but once it's been toggled, then it works. On the test channel it works for both though. I'm just glad it's working. Thanks again.
    – Jonah Vo
    Mar 11, 2013 at 22:20
  • Hrm, you have to toggle it to register? Can you make sure you're running the version from GitHub? github.com/pixelandtonic/pt_switch Thank you!
    – Lisa
    Mar 11, 2013 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.