Taxonomylist Plugin: problem with tags displaying empty pages

Hello everyone

Setup

On my Grav site, I have a main blog page with articles and subblogs with articles, a structure like this:

/blog
  /article-1
  /article-2
  /subblog-1
    /article-3
  /subblog-2
    /article-4

Each article has one or more tags, and every article of a subblog has at least the same tag as the subblog. Now I’m facing the problem that the taxonomylist plugin displays emtpy tags.

Problem

On my main blog page /blog, all tags get displayed, with articles, subblogs and those articles. No difficulties here so far. But then on a subblog page like /subblog-1, it not only displays tags of the articles, but also all other used tags, which aren’t used on the subblog.
Because of that, I get a page looking like this:


As a reference, ‘Tutorials’ is the main blog page and ‘Seiten’ is the subblog, the page visited. Since there are no articles in this subblog with the tag ‘Login’, it displays an empty page. The URL/ Path is /tutorial/seiten/tag:Login, which means that it gets only the articles of the tag ‘Logins’ in the subblog ‘Seiten’

possible Solutions

Two possible solutions come into my mind, but I don’t know how to do it or where the problem is that it doesn’t work:

  • S1 (Preferred): The plugin only displays the tags used within this subblog. So it is like a combined filtering, since it filters only articles below this subblog in general, and optionally a tag within this subblog.
  • S2: On the subblog, all tags of the entire blog page (main blog) get displayed. But when selecting a tag, it displays all articles, not only the ones from the subblog.

What I’ve tried

According to the README of the plugin, I tried including the taxonomylist with this, where I also tested it out with/ without the of_page and children_only separately and combined:

{% include 'partials/taxonomylist.html.twig' with {
    'base_url':new_base_url, 
    'taxonomy':'tag', 
    children_only: true, 
    of_page: page.parent
} %}

I also tried setting of_page as a string, with the collection syntax (@), changed it to page.descendants so it gets only pages below, and some more ideas I had, but none of them solved the issue.

This is the partials/taxonomylist.html.twig file from the theme:

{% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags(pf_page) : taxonomylist.get() %}

{% if taxlist %}
<span class="tags">
    {% for tax,value in taxlist[taxonomy] %}
        {% set label_class = uri.param(taxonomy) == tax ? 'label-primary' : 'label-secondary' %}
        <a class="label label-rounded {{ label_class }}" href="{{ base_url }}/{{ taxonomy }}{{ config.system.param_sep }}{{ tax }}">{{ tax }}</a>
    {% endfor %}
</span>
{% endif %}

Ok I really feel stupid for this, but it happened that I edited the template with the include from a theme I inherited and overridden. I figured this out when I was working on another enhancement which required the same template to be edited, but it had missing parts I made on my theme.

Sorry again, shit sometimes happens, and often it’s the programmers’ fault, not the programs’.

Have a nice week everyone!

Still having a problem with the main blog page.

On subblogs, it now displays only the tags within this blog. But on the main blog page /blog, it can’t access the tags from articles of a subblog.

I’m still not very good with PHP, but my theory is that this is because of the getChildPagesTags function in the plugins /classes/taxonomylist.php, which only gets the children of a page and not all descendants. That would mean that it can get the tags of its articles and the subblogs, but not the articles of a subblog.

Am I right with assuming that there is no way for the plugin to access these tags too? Except for forking the plugin and do a little rewrite of the function?