Skip to main content
Editing answer to be more what the OP asked for.
Source Link
Ryan
  • 2k
  • 1
  • 16
  • 24

You will need to use JavaScript, either AJAX calling to a template that re-runs a new Twig for loop and returns the results in HTML, or a framework like Vue or React in conjunction with P&T's Element API that will create an endpoint of your section's entries in JSON format.


If you don't mind a page refresh, you can filter your entries dynamically using craft.request to grab pretty much whatever you want: a segment from the URL, query string, post data, etc. So basically, when the form submits, your redirect url should go to that page and either you add submitted data to the url via get or grab the data via post.


Also, fyi, you have some fundamentala syntax errorserror in theyour code you posted: no = sign when setting a variable, missing a %) inat the end of your else.relatedTo tag, missing double curly braces for printing a variable, etc.;)

You can filter your entries dynamically using craft.request to grab pretty much whatever you want: a segment from the URL, query string, post data, etc. So basically, when the form submits, your redirect url should go to that page and either you add submitted data to the url via get or grab the data via post.


Also, fyi, you have some fundamental syntax errors in the code you posted: no = sign when setting a variable, missing a % in your else tag, missing double curly braces for printing a variable, etc.

You will need to use JavaScript, either AJAX calling to a template that re-runs a new Twig for loop and returns the results in HTML, or a framework like Vue or React in conjunction with P&T's Element API that will create an endpoint of your section's entries in JSON format.


If you don't mind a page refresh, you can filter your entries dynamically using craft.request to grab pretty much whatever you want: a segment from the URL, query string, post data, etc. So basically, when the form submits, your redirect url should go to that page and either you add submitted data to the url via get or grab the data via post.


Also, fyi, you have a syntax error in your code: missing a ) at the end of your .relatedTo ;)

Source Link
Ryan
  • 2k
  • 1
  • 16
  • 24

You can filter your entries dynamically using craft.request to grab pretty much whatever you want: a segment from the URL, query string, post data, etc. So basically, when the form submits, your redirect url should go to that page and either you add submitted data to the url via get or grab the data via post.


Also, fyi, you have some fundamental syntax errors in the code you posted: no = sign when setting a variable, missing a % in your else tag, missing double curly braces for printing a variable, etc.