2

Is there a way to define default values in set_list?

Basically, I want to set 3 variable to:

{stash:var_run_here}no{/stash:var_run_here}
{stash:var_type}none{/stash:var_type}
{stash:var_title}{url_title}{/stash:var_title}

Then overwrite them, depending on a playa value or checkbox values further in the set_list grouping. Something like:

    {if is_global == 'y'}
            {stash:var_run_here}global{/stash:var_run_here}
    {if:else}
        {run_on_these_pages}
            {exp:switchee variable = "{url_title}" parse="inward"}
                {case value="{segment_2}"}
                    {stash:var_run_here}yep{/stash:var_run_here}
                {/case}
            {/exp:switchee}
        {/run_on_these_pages}
    {/if}

    {exclude_from_these_sections}
        {exp:switchee variable = "{option_name}" parse="inward"}
            {case value="{url_title}"}
                {stash:var_run_here}yep{/stash:var_run_here}
            {/case}
        {/exp:switchee}
    {/exclude_from_these_sections}

So that this is the get_list part:

{exp:stash:get_list name="fma_list" parse_conditionals="yes" unique="yes" process="end" orderby="var_type" sort="asc" limit="999"}
  Title: {var_title}<br>
  Run On This Page: {var_run_here}<br>
  Type: {var_type}<br>
{/exp:stash:get_list}
4
  • Yes it is possible but what's the problem you're having ?
    – Ian Young
    Apr 20, 2013 at 9:52
  • Can you also include where you {exp:channel:entries} tag is included in your code?
    – Ian Young
    Apr 20, 2013 at 9:53
  • i think you should parse_tags and parse_conditionals on the set_lest part.
    – GDmac
    Oct 28, 2013 at 14:27
  • this is actually not working for me with stash in EE3. ``` {stash:url}my default title{/stash:url} //new list entry created here {stash:url}{url_title}{/stash:url} ``` when I want to overwrite a varible like in the code example, a new entry in my list is created. anybody has the same issue? Jul 21, 2016 at 12:18

1 Answer 1

2

Yes, you can do this. Just put those default values at the top. Those values will be replaced if they're set later in the order.

{exp:stash:set_list name="fma_list" ... }
    {exp:channel:entries ... }
        {stash:var_run_here}no{/stash:var_run_here}
        {stash:var_type}none{/stash:var_type}
        {stash:var_title}{url_title}{/stash:var_title}
        {if is_global == 'y'}
            {stash:var_run_here}global{/stash:var_run_here}
        {if:else}
            {run_on_these_pages}
                {exp:switchee variable = "{url_title}" parse="inward"}
                    {case value="{segment_2}"}
                        {stash:var_run_here}yep{/stash:var_run_here}
                    {/case}
                {/exp:switchee}
            {/run_on_these_pages}
        {/if}

        {exclude_from_these_sections}
            {exp:switchee variable = "{option_name}" parse="inward"}
                {case value="{url_title}"}
                    {stash:var_run_here}yep{/stash:var_run_here}
                {/case}
           {/exp:switchee}
        {/exclude_from_these_sections}
    {/exp:channel:entries}
{/exp:stash:set_list}

Your Answer

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

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