Skip to main content

Filter Tags Module

This Joomla 4.x and 5.x module allows you to filter your category, featured or archive blog on a chosen tag. When you click on one of the tags, the category blog is updated and only show the articles that have the chosen tag.

This is a refactoring of the Tags - Filter by Rene Kreijveld.

This version was created to migrate older Joomla 3 website to Joomla 4 and 5

This module filters the tags within the current menu (Therefor only showing articles). Thus, it uses the settings and layout (overrides) of the view. This is different from showing the tags as part of a Tag-menu items. There it shows not only articles but all content with tags like tages categories. And it uses the tag layout.

This module is intended as a lightweight solution for basic filtering, just on tags. If you need a more complex solution, like filtering on custom fields or multiple tags you might need an extension like jfilters.

Page builders

The module works with any page builder using Joomla's Articles Model. Some page builders have their own queries that do not handle the filter_tag parameters. Yootheme for example, if you create dynamic content with  custom → articles. It works fine if you use page → articles

empty filter_tag=

See the persistent filter option  below.

Category List Layout

The module works with the category list view. However, the behavior might appear a bit odd depending on your site's structure. 

Tag(s) Selection in Menu

The module will work if you pre-select tags in the menu configuration. However, the tag selection in the menu and this module conflict, as they use the same query parameter. So there are some side effects:

  • This module will show all tags for the documents in the given category, ignoring the selection in the menu
  • The tag selected in the module will override the selection in the menu
  • The Tag-links will point to the first suitable menu item based on the category. In the eyes of the beholder, which are Joomla's not Your's.

Highlight active tag

The module adds the active class to the currently selected tag. The effects of this class depend on the used template.

Another option is to show the active as plain text instead as a link. The 'bootstrap' layout shows an example of how to implement this.

If you need other classes then create an override.

SEF URLs

Although it's probably not a good idea to have the filtered pages indexed by search engines, you can make the links prettier using the SEF Plus Plugin

Options & Settings

Layout

The module comes with a few basic layouts.

  • 'Default' is a simple, unnumbered list.
  • 'Bootstrap' uses the item-group style.
  • 'Tag cloud' 
  • The 'Hide on Page' layout is an example how you can hide the tags on subpages in case of pagination.

There are too many different templates to suite all. Please create an override to customize the layout to your needs. Feel free to use the contact form if you have any questions.

 

Sorting tags

The tags can be ordered on title, the tag order or frequency (number of times a tag is used) and random.

Show "No tags found" text

Display a message if there are no tags at all for the current view.

You can change the text using a language override on MOD_FILTERTAGS_NO_TAGS_FOUND or creating a template override.

Add noindex / nofollow Robots tag

The resulting pages with a query are not very search engine friendly and basically duplicates of the category pages. This option adds a <meta name="robots" content="noindex,nofollow"> to the <head> section of the page and a rel="nofollow" to the links in the module.

 

Always show reset

Whether or not to show the Reset Link if no tag filter is active.

Use a language override on MOD_FILTERTAGS_RESET_FILTER to change the string.

Persistent Tag Filter

For the category views, Joomla remembers the state of the filters, including the tag filter, within a session. Thus, if you navigate forth and back and revisit a page with a tag filter, the filter is still active even without a ?filter_tag=<value> query in the URL. An empty query value is needed for a reset. Therefor, the reset button goes to https://example.com/page?filter_tag=<empty> and not https://example.com/page. 

The featured and archive views are never persistent. This is implemented in the Joomla CMS itself. Even the default filters of the archive view are not remembered.

As this module run's after the component, this behavior can not be changed from within the module. That would require an additional plugin. The better solution would be consistent behavior of Joomla itself.

If you have several of this modules on the same page, the last one should have this option set to 'No' if you want to disable persistence.

Redirect on empty filter

In case of a reset (with persistent filter on) the link will go to a page with an empty query like: index.php?filter_tag=

If you consider this ugly, enable this option to redirect users to the menu-start. The redirect via the intermediate page is needed to reset the internal state of the filter.  (That's the persistent part).

With this option turned on also queries to non-existing tags will be redirected.

 

Include & Exclude Tags

These options allow selecting tags to be included or excluded in the tags list.

Tags for display in the module will have to meet the following conditions:

  • Must be in one of the documents selected by the menu configuration
  • Must be in the include list if set
  • Must not be in the exclude list (if set)

If the children option is set also the children of an included or excluded tag are added to the conditions. Not that is option/behavior does not exist in the tag filters in other location in Joomla.

These options do not filter the articles directly. Neither does it prevent the display of tags in the articles meta data.

The 'internal only' tag is not visible in the module. But it is shown as part of the meta data of the article.

 

 

French translation by: Marc SAVART - from sil51.com.

This module is not related to the BLC Component