All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Trying to get conditional if status to work (Stash involved)

MarcTiedemann 9 Sep 2013 17:01 question, complete

Hello,

I just implemented a solution to show entries with the status "Draft" on the frontside to content editors with the help of Stash. Now I'd like to conditionally show a graphic so that Editors will be able to clearly see that the entry is not yet published.

I tried something like "{if status == "draft"}{/if} but it isn't working. I am pretty sure that this must have something to do with parse order but I am not really good at that.

My template is basiclly built like this:

Stash Viewmodel-Template containing this (abstracted):
{exp:low_variables:pair var="my_products" multiple="yes" status='{exp:stash:get name="functions:preview-status"
file="yes"
parse_tags="yes"
parse_conditionals="yes"}'
parse="inward"}
{if status == "draft"}{/if}
{productdiv}

{/exp:low_variables:pair}

The "{productdiv}" is also a Low Variable and ultimately the if conditional must go in there in the end. I just placed it outside for easier testing.

I know that this isn't ideal to really show what I am doing but I don't really know how to do this better.

Do you have any idea on how to do this or am I simply wanting too much here?

Thanks and Cheers,

Marc

Replies

  1. Low 10 Sep 2013 07:34

    If you're using a tag as a parameter value (which I never recommend), you'll have to put the whole tag on a single line, so no line breaks.

    What kind of variable is my_products? If it's a Select Entries type, then looping through them like that won't give you the entries themselves, just their IDs. But perhaps you're using Playa?

    Also, not really familiar with Stash, so if you get it working without Stash, then maybe Mark Croxton can help you out better on how to implement this with Stash.

  2. MarcTiedemann 10 Sep 2013 09:06

    okay, I took out the line breaks.

    And yes, the "my_products" var is Playa.

    And after putting the template in a non Stash Enviroment and playing around with the Statuses a bit I noticed that it must have simply been a "uppercase/lowercase" problem.

    I created a new status "Draft" in Statuses default group. As soon as I put it like {if status == "Draft"} it worked.

    Sorry about that!

    Have a great day!