Filtering and Conditional Display of Articles

Joomla provides no mechanism for filtering menu items e.g. Category Blog views,  based on the value of custom fields.  EasyLayouts make this functionality available in Joomla.  This article explains how to use this feature.

On the EasyLayouts Demo site (https://demo.easylayouts.net) we showcase EasyLayouts to show how you could set up a site to list chefs, restaurants and recipes with different layouts, custom fields and interrelated linkages.  One obvious need when showing recipes is to search for recipes with specific ingredients or allergens.  We have a menu item to show this functionality - https://demo.easylayouts.net/recipes/excluding-wheat

This is done using EasyLayouts menu item filtering - EasyLayouts adds a new tab to the menu item editing page 'Custom Field Conditions':


Menu Item Constraint from EasyLayouts Demo Site

The constraint system starts with a question to say if matching items should be hidden or shown and if ALL or just SOME of the conditions need to matched.


How should constraints be combined and applied

In this case we choose to hide all articles that match ALL the constraints.  Looking at the constraints in more detail - the first input allows you to select a specific custom field, the second how the value of this field should be tested


Field selection and how to test its value

In this case we have selected 'Allergens' and to show/hide the articles when its value is equal to the specified value.


We have selected allergens with a value of Wheat

The custom field value field should adjust to take account of the field type e.g. in this case a multi-select list of possible allergens.

Key Point

Please note that multi-select fields will be an 'OR' match - we coding the test this way since otherwise it would only match articles with the exact same combination of select list items selected.

So if you wanted we wanted to hide recipes which have Wheat or Crustaceans in their allergen list we could setup our menu item as follows

 


Image Caption

BUT If we wanted to hide recipes which have BOTH Wheat AND Crustaceans in their allergen list we should setup our menu item as follows:


Combined allergen test

 


Published: 08 September 2017

Demo Site

You can access our demo at https://demo.easylayouts.net.

You can easily switch EasyLayouts off and on again via a special module on the demo site and can also access the backend to experiment with the layouts. The demo resets every hour so bear in mind that the demo looks a bit odd that someone else may have changed the layouts before you viewed the page.