I am looking for a way to show Joomla 4 articles in a category blog filtered by one (or more) of my custom fields. - The category blog settings in the backend seems only allow to filter by category, tag and other default article parameters. - Is filtering a blog by custom fields possible, anyways?
1 Answer
You can filter on Custom Fields via multiple ways:
- filtering via JavaScript + CSS. This will load all articles, but can CSS hide (display:none) them using some JavaScript. The articles are still there in the HTML source but just not visible.
- filtering via PHP in Joomla's Articles Model. This will load only the articles that fit to the filter state. I used this technique for a client project: I've programmed a System Plugin that overrides Joomla's Articles Model in the
populateState
method. And I programmed a Module to set the Filters. This way I was able to filter the Articles based on Filter Options using some Custom Field Fields.
There are some 3rd party extensions available that add filtering functionality to Joomla's articles:
- JL Content Fields Filter (for J3 + J4) https://extensions.joomla.org/extension/jl-content-fields-filter/
- JFilters (for J4) https://extensions.joomla.org/extension/jfilters/