Switchee
ExpressionEngine 1.x, ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4
Back to this add-on's main page
View Other Add-ons From Mark Croxton
Testing Custom Field
General
Todd Richards
|
Posted: 02 April 2014 07:40 PM |
|
|
|
I’ve got a custom field named {resource_visibility}. Basically, when the client enters something into their resource bank, they can use a Field Pack Switch to set it for Members (default - value=“members”) or Public (value=“public).
My goal would be to use a Switchee statement to run a certain set of code based on members or public.
If I cal the custom field in the template, I get the correct value. However, my Switchee statement isn’t working.
{exp:switchee variable="{resource_visibility}" parse="inward"} {case value="public"} Public {/case}
{case value="members" default="yes"} Members {/case} {/exp:switchee}
This is inside a {exp:channel:entries channel=“resources” ....} tag.
Any thoughts? I just updated to 2.1.1 today.
Todd
|
|
|
Todd Richards
|
Posted: 02 April 2014 07:44 PM |
# 1
|
|
|
In addition, I tried to use ifelse and it’s not working either…
{exp:ifelse parse="inward"} {if resource_visibility == "public"} <p>This is public</p> {if:else} <p>This is members</p> {/exp:ifelse}
|
|
|
Todd Richards
|
Posted: 03 April 2014 11:19 AM |
# 2
|
|
|
OK, last update - and I may have answered my own question….
I was using an {exp:ifelse parse=“inward”}{/exp:ifelse} statement earlier in the template too. Am I only able to use one in a template? When I took that one out, then my issue above worked as expected with a {exp:ifelse parse=“inward”} statement and a Switchee statement. So I’m guessing that is a limitation?
I’ve used Switchee many times - love it. But I don’t think I’ve run across this before (that I can think of)?
Todd
|
|
|
Mark Croxton
|
Posted: 03 April 2014 11:26 AM |
# 3
|
|
Developer
|
I’d guess your earlier {exp:ifelse} was throwing an error. That can happen if you’re trying to evaluate variables which are unparsed at the point it runs. Turn on debug=1 in your index.php file to view PHP errors. You can use {exp:ifelse} as many times as you need, in principle.
|
|
|
Todd Richards
|
Posted: 07 April 2014 11:50 AM |
# 4
|
|
|
Thanks Mark. I believe I’ve got it figured out.
|
|
|