The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Add view filters within your display-frm-data shortcode

Labels

This Discussion is public

Notifications

Would it be possible to add parameters to the display-frm-data shortcode with which we could add filters directly from within the shortcode?

For those who hate suspense, the answer is yes.

The Scenario

I have seven different views created and added to one page and the only difference is a single filter in each. In this case it filters by date so I can display results linked to today, tomorrow, next day, etc. to create a one-week view of results.

This will work fine, but it can quickly get out of control when you need to make changes to the content display across several views. Not to mention that, as a developer, it's like nails on a chalkboard to repeat the same code over and over needlessly.

The Solution

The display-frm-data shortcode already lets you create and pass parameters to the view. Just make up a unique name and give it a value. Something like this:

There are no views with that ID

In this case, next-7-days is the name of the view and datefilter is the parameter name I am going to "get" for my filter. The filter is essentially...

Show where "Post Date" is equal to [get param=datefilter]

Post Date is the name of a field that contains the date this post is relevant. You might be able to use other date related fields, such as the creation date or updated date, but for this purpose a future date is specified when the entry is created so we used that field.

The datefilter parameter will contain the content added within the shortcode, so to carry this out for a week I would add something like this to the page I want to display the views...

There are no views with that ID
There are no views with that ID
There are no views with that ID
There are no views with that ID
There are no views with that ID
There are no views with that ID
There are no views with that ID

Now, rather than having seven different views to update I only have one view that updates it's filter as needed.

Hello

It's what I am looking for, unfortunately I was unable to archive :(

where did you put the code
Show where "Post Date" is equal to [get param=datefilter]

Tks for your help
guillaume

Hi Guillaume,

You can add that filter in your View's Settings. Do you see the Filter option?

Discussion closed.