Support is currently limited. Click here to see our hours of operation.
Help Desk

Filter down by two categories

Labels

This Ticket is public

Notifications

Hi,

I'm hoping I can get some guidance on filtering. I have a view which shows user-submitted recipes created from a Formidable form (create posts). The search form I've built is a separate form that offers two dropdowns.

Course: Breakfast, lunch, Dinner, Desserts, Snacks.

Nutrition: Low-Calorie, High-Calorie, High-Protein.

Filtering individually is no problem. After submission, I use a custom link to send the user to the right view ie: recipe-search-results?course=Dinner. Then I was using your custom [if_get_param] shortcode to display the correct view. In the views themselves I know I can use a filter to say Course is equal to dinner and show Calories ascending etc.. but from the parameter, if I have something like ?course=Dinner&nutrition=Low-calorie, I don't know how to whittle that down as you can (I believe) only look for one parameter with that shortcode.

Using course equals in the views filter for some reason doesn't work. I've tried all the variations: without speech marks, all lower-case, leaving out the hyphens etc.. but nothing seems to work. By my understanding, if all filters in a view aren't met, the view won't show. But I'm finding with the just mentioned filter in the view all entries are showing. The only filter that is working is admin approved equals published.

Does anything stand out to you that I might be getting wrong there?

Thank you,

Jan

Hello Jan,

I'm not sure I'm understanding your setup completely. Do you have:
1. Form A where a user submits a recipe, and in this same form they select a single course option, and a single nutrition option?
2. Form B which is a search form that redirects to the view, with parameters in the URL i.e.
recipe-search-results?course=[x]&nutrition=[y] where x and y are field IDs in the search form itself?
3. A view which has in Filter settings:
course is equal to [get param=course]
nutrition is equal to [get param=nutrition]

Please let me know if all 3 conditions are met in your setup.

Regards,
Matthew

Hi Matthew,

Thanks for getting back to me. To answer your questions:

1, Yes to the single course option. The user has a course dropdown within the recipe creation form (Form A) where they have to select the course. This is why I'm a little confused as to why the get param=Dinner filter isn't working in the view. *Update: I noticed in Q3 the filter you wrote was get param=course. This does infact work and with dinner being the selection in the url, the view takes you to dinner.*
No to the nutrition field. The nutritional factors are text fields within a heading section where the user/author has to work out the nutrition of the meal and type it in. Eg, Protein(g) 38, Calories(kcal) 520. The author just types the number in to the corresponding field name.

2, Yes to all.

3, Yes to Course now, thanks to you.
No to Nutrition as that is the heading name and doesn't show up as an option. The only available options are the text fields contained within. Eg, Calories and Protein (and Fats and Carbs but they won't be available in the search.)

So I guess the problem is how I'm asking for nutritional info to be filled in. Any ideas on how I could change how they're inputted to make this work?

Thanks,

Jan

Hello,

What are the different thresholds for the levels you are using for the nutritional categories? I.e.:
a) What is considered as high protein?
b) What is considered as high calories?
c) What is considered as low calories?

One thing you could do is have each nutritional option as it's own checkbox with a single option, i.e.:
High Protein?
Yes √

High calories?
Yes √

Low Calories?
Yes

Make sure to use conditional logic to hide Low Calories field if High calories is selected and vice versa.

Then change the redirect URL as follows:

recipe-search-results?course=[x][if y equals="Yes"]&protein=20[/if y][if a equals="Yes"]&high-calories=600[/if a][if b equals="Yes"]&low-calories=500[/if b]

Where y is the field ID of the protein checkbox, a is the field ID of the high calories checkbox, and b is the field iD of the low calories checkbox. Change the numbers to match the thresholds you are using for each category.

Then add some filters to your view:
1. Protein(g) is greater than or equal to [get param=protein]
2. Calories is greater than or equal to [get param=high-calories]
3. Calories is less than or equal to [get param=low-calories]

Does that make sense?

Hi Matthew,

Sorry for the late reply. If I get stuck on something I find I have to move on to something else as I've a mountain of work with the current project.

Although not ideal (i'd really like the Dinner - High-calorie filter to show all admin approved dinner posts with descending calories rather than within a specific range,) it would certainly cure the filtering issue.

I've been thinking, now the get param has been sorted with the course, it may well be possible to use 'if_get_param="nutrients" value="calories-high"' >> then show all views for the filtered courses with calories descending as the order. Although I am yet to try this.

I'll have a go probably tomorrow, if that doesn't work I will certainly implement your suggestion. Which took me a good few reads to make sense of by the way :) I'd have never have thought of it. Thank you.

I'll leave the ticket open for now if that's ok?

Jan

Sounds good! I'll leave the ticket open, so whenever you have time to respond is just fine.

Regards,
Matthew

Ticket closed.