0

I have code that looks like

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

that uses javascript to indicate the selected city. So when "Anchorage" for example is selected from a dropdown at the top of the page

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

displays "Anchorage". I need to use this selected city in a channel entry loop. I've tried doing this using Stash, as in the code below, but it is not working. Is there any way to save the city in a form that can be used by Expressionengine?

{exp:stash:set_list name="city2" parse_tags="yes" trim="yes"}
{stash:city3}<label class="city"></label>{/stash:city3}
{/exp:stash:set_list}

{exp:stash:get_list name="city2" parse_tags="yes" trim="yes"}
{exp:stash:parse unprefix="nested"}
{exp:channel:entries channel="place" search:city="{city3}" dynamic="no"}
{title}
<br />
{if nested:no_results}
No results
{/if}
{/exp:channel:entries}
{/exp:stash:parse}
{/exp:stash:get_list}
0

Channel entries tags run before the page is sent to the browser, so in order to pull this off you'll need to fetch the extra channel data from a dedicated template via AJAX.

When your JS updates the city in the DOM, simply send off an AJAX request to a new template and use URL segments to filter the output. When the response comes back you'll then need to inject it back into the DOM.

1
  • Thanks for the information. I guess it's more complicated than I hoped and I'll need to hire a developer to write the code you explained is needed. I'll come back here to confirm it worked. – Geoff Jul 18 '16 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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