1

Is there a way to set parameters from front-end user input?

Let's say I have a page that displays a list of entries. On that page, I have a form select called paidStatus with options notReceived, received, and paid; and another form select called order with options asc and desc.

Then, in my template code, I want to grab the list of entries:

{% for entry in craft.entries.section('sectionName').order('postDate post.order').find() if entry.paidStatus == post.paidStatus %}

with order and entryStatus being populated from the submitted form selects. That way I can change the criteria used to generate the list of entries on the fly.

1 Answer 1

1

Yes, you can pass in a variable into the parameters and to get the query string values use craft.request.getQuery().

I can recommend this blog post by Jérôme Coupé for a great introduction to setting up the form and the criteria model filters:

Combined searches and filters using Craft

You should also have a look at other questions tagged with "form".

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.