4

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 1

4

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:

3
  • I also suggest to check one of the suggested 3rd party extensions. No need to re-invent the wheel on that.
    – Sakis
    Jul 14, 2022 at 13:36
  • @pe7er could you share your System Plugin code especially on how you overwrite Joomla's Article Model in the populateState method.
    – cappu
    Jul 23, 2022 at 20:23
  • I thought of writing a Plugin for this. It works fine on small projects, but may run into performance issues on larger ones. extensions.joomla.org/extension/authoring-a-content/…
    – cappu
    Sep 1 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.