0

I’m having trouble getting a stash variable to work as a parameter in a channel entries loop. I have not had this problem before so I wonder if it may have something to do with the nature of the variable. It is coming from javascript code and it is called by the code . This produces the result of a city selected elsewhere on the page (for example, Portland). Since that code can’t be used in the channel entries tag I am using the following stash code:

{exp:stash:set
    name="city1"
    parse_tags="yes"
    process="end"
    trim="yes"}

    <label class="city"></label>

{/exp:stash:set}

This seems to work correctly and both {exp:stash:city1} and {exp:stash:get:blah name='city1’} produce the result of the selected city (for example, Portland). But it doesn’t work in the following expressionengine code:

{exp:channel:entries
    channel="place"
    search:city="{exp:stash:get:blah name='city1'}"
    parse="inward"
    dynamic="no"}

    {title}
    <br />

    {if no_results}
        No results
    {/if}

{/exp:channel:entries}

I’ve tried as many variants as I can think of using additional stash parameters but I need help.

Thanks, Geoff

1 Answer 1

0

Unfortunately the parse="inward" trick doesn't work with the search: parameters. You need to pass the variable as a placeholder to the channel entries tag instead. For example:

{exp:stash:parse unprefix="nested"}
   {exp:channel:entries
       channel="place"
       search:city="{stash:city1}"
       dynamic="no"}

       {title}
       <br />

       {if nested:no_results}
           No results
       {/if}

   {/exp:channel:entries}
{/exp:stash:parse}

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.