I’m stumped on something. I’m trying to (using AJAX) allow users to filter events by their location. So you can choose either Region or Country from selects that are populated with the addon REEgion Select. Whatever you select then becomes segment_3. Pretty straightforward. If you chose a Region, it’s no problem to just use that segment as the search, but because there’s some overlap between the two letter codes (CA is Canada and California), I created a conditional to determine what is being returned, and am trying to use stash to get that conditional variable into the search function of the {exp:calendar:events} tag.

This is that tag: {exp:calendar:events event_limit="30" channel="calendar_events" date_range_start="today" date_range_end="1 year" search:address='{exp:stash:get name='region_search' random}' dynamic="no”}

Here’s the stash variables I created: {exp:stash:set name="region_stash"}{exp:reegion_select:countries}{if segment_3 == "{region_alpha3}"}{region_alpha2}{/if}{/exp:reegion_select:countries}{/exp:stash:set}

{exp:stash:set name="region_search"} {if '{exp:stash:get name="region_stash" random}' == ''} "region":"{segment_3}" {if:else} "country":"{exp:stash:get name="region_stash" random}" {/if} {/exp:stash:set}

{exp:stash:get name="region_search" random}

outside of the tag, this stashed variable works great and renders no problem. Do you guys know what I’m doing wrong?

Here it is in action. Thank you!

  • Turn on Template Debugging in EE and see if the contents of search:address="" are parsed and do not instead show all (or part of) the unparsed Stash code. Also make sure your address field is set to be searchable in EE.
    – Solspace
    Nov 3, 2015 at 5:09

1 Answer 1


Here you can find a description on how to solve your issue.

  • Thanks for getting back to me @Balloonatic! I had already seen that post, and tried to apply it again. It didn't fix it for me though. the Trim tag is useful to know about, so I added it, but my code is actually already formatted without spaces, I just tried to make it easier to read here. Any other thoughts? Nov 2, 2015 at 7:52
  • I took a look at your website. The Ajax call is like this: /test-site/events/in/CAN/. This would mean the region code is segment 4 instead of segment 3. Could this be your problem? Also I would like to point out that every time a country is selected, the remodel script is being called. So I would remove that script tag from you ajax call. As soon as you click the drop down box to select a county an ajax call is being made without a selection. (/test-site/events/in//) Nov 2, 2015 at 9:09
  • Good catch with removing the remodal script from the ajax. I did that and removed the ajax call unless a selection was made. As far as segment_3 or segment_4, unfortunately, EE is installed on /test-site/ so /events/ is segment_1 Thanks again for your help! Let me know if you have any other thoughts. Nov 2, 2015 at 10:25
  • It works a lot better now. :) In your calendar tag you have used the stash variable region_search, but shouldn't this be region_stash? Nov 2, 2015 at 11:24
  • No, both of those variables are set, and region_search is the full one. You can see that this prints the text 'country':'US' or 'region':'NY' depending on which select was selected Nov 2, 2015 at 18:52

Your Answer

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

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