0

i'm using Solspace Calendar to show events around an area on dates the user selects. I have made the results page with a combination of Calendar + Stash and it is working really fine.

I get the results like http://domain.com/index.php/results/Athens/2/2017/01/07/2017/02/28 where Athens is a custom text field for cities, 2 is category_id for activities (cinema, dance, etc) and the rest is start_date and end date that the user selects to check if there any events.

Now, the problem is that i need to make a form with 3 elements -a category dropdown menu, a city dropdown menu and a datepicker for daterange. All that is good and normal.

So i need to make the form to point to the specific above url, passing the 3 elements to the url segments. Actually what i want is to make the search form to create a link in the above form.

Is that possible? I tried some variations either with {exp:search:simple_form} or plain html form, nothing works.

Shall i make the submit button as a link? And how i will pass the values from the dropdown menus to this link?

Seems like a riddle to me.

Any idea will be welcome.

Thanks for your time

4
  • Seems like you could just use url segments but how that reacts with your template tags is yet to be decided. So maybe something like /results/cat_id/city/date_start/date_stop. You'll need to be wary of bogus segments but do-able Apr 15, 2017 at 8:59
  • i have this <form action="results/{locality}/{category_id}/20170107/20170228" method="get"><select name="category[]"> {exp:channel:categories category_group="1"} <option value="{category_id}"{selected}>{category_name}</option> {/exp:channel:categories}</select> <select name="city" class="select"><option name="locality" value="">Select city</option> {exp:query sql="SELECT DISTINCT field_id_11 AS locality FROM exp_channel_data WHERE channel_id=1"} <option name="locality" value="">{locality}</option> {/exp:query} </select> <button type="submit" value="Search"/></form> Apr 15, 2017 at 18:34
  • but not working Apr 15, 2017 at 18:35
  • Don't make it a form, probably just use JS to create a URL of the selected values in the 'form' and the "submit" is just a dynamic link populated by the selects. Forms will want to do things which are overkill. What you're basically seeking to do is create consistent URL structure and have the URL dynamically populated by selections. Apr 16, 2017 at 8:30

1 Answer 1

0

Finally i went with js and it worked

form action="" onSubmit="urlGen(this);" method="get" target="_parent"

then i populated the fields with ee values giving an id to every select dropdown and then i run the js

function urlGen(f){ var i1 = 'http://domain.com/index.php/results/'; var i2 = f.city.value +'/'; var i3 = f.category.value +'/'; var i4 = '2017/01/07/2017/02/28/' f.action = i1 + i2 + i3 + i4; return true; }

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.