Illegal offset type in isset or empty in taxonomylist

Hello

When I activate the taxonomylist plugin, the result that the page shows me is the following:

An exception has been thrown during the rendering of a template (“Illegal offset type in isset or empty”)

This happens with the twig template of the plugin and with the one that I have customized.

How can I correct this problem?
Thanks

Hi @pmoreno

A particular theme ?
Look at the include file

{% include 'partials/taxonomylist.html.twig' with {'base_url':new_base_url, 'taxonomy':'tag'} %}

look at parameters

[ ... ] with {'base_url':new_base_url, 'taxonomy':'tag'} %}


On quark theme, I reproduce the problem by changing

'taxonomy':'tag' to 'taxonomyLoremIpsum':'tag'

Sincerely
Kit

Hi @kit

Thank you for your contribution, but with your suggestion I do not get the desired result. First, for the code you propose to work, the variable ‘new_base_url’ must be declared (as in Quark Theme) with the following lines:

{% set new_base_url = blog.url == '/'? '': blog.url%}

Based on this scenario, I get the following results:

If I am on the home page or other and click on Tag1, Tag2 or others (in the Sidebar), the path shown in the browser is:

http://localhost/tag:tag1 or
http://localhost/tag:tag2 or
http://localhost/tag:tag3

showing therefore an error, since that is not the address of the website.

What am I missing to configure it correctly?

@pmoreno, After some playing around, it seems the error is thrown by this statement in taxonomylist.html.twig:

{% for tax,value in taxlist[taxonomy] %}

I suspect that your parameter taxonomy in the include statement for taxonomylist.html.twig is not passing a string, but an object/array.

Would you mind:

  • showing your include statement of taxonomylist.html.twig
  • and if the value of taxonomy is a variable:
    • showing the code that defines the variable?
    • execute a dump of the variable like {{ dump(variable) }} and examine that dump in the debugbar/clockwork.

@pmoreno, Just curious, have you made any progress on this issue?

Hi @pamtbaau.
I have not been able yet for personal reasons. As soon as I can I will follow your advice to see if it can be solved.

Hi @pamtbaau

In the end I have achieved what I want, partially, only with the blog collection, in this way.
First I define the variable with the absolute path to the site and the blog path:

{% set new_base_url = base_url_absolute ~ site.blog.route%}

And then I include it with:

{% include 'partials / taxonomylist.html.twig' with {'base_url': new_base_url, 'taxonomy': 'tag'}%}

But this only works for the blog collection.
How do I get it to show me all the tags of all the pages of the site?

Thanks.

@pmoreno, Your “solution” doesn’t give insight as to why you got the error “Illegal offset type in isset or empty”.

Would you mind explaining what the cause was of the error and how it has been solved?

How do I get it to show me all the tags of all the pages of the site?

This is imho a new question which is not related to the title of the current post. Please open a new topic for this question.

Hi @pamtbaau
Sorry to have mixed two issues into one. Indeed the last question is for another post. Regarding the original question, the error is solved by passing parameters to the call to the taxonomylist plugin.

{% include 'partials / taxonomylist.html.twig' with {'base_url': new_base_url, 'taxonomy': 'tag'}%} 

previously defining the variable ‘new_base_url’,

{% set new_base_url = base_url_absolute ~ site.blog.route%}

Thanks for the help