Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Taxonomies: Is "category" and "tag" mandatory?

Started by Rubén Gómez Antolí 9 years ago · 5 replies · 1907 views
9 years ago

Hi all,

This is my second problem with Grav (first was with comment system) and I have some dudes about:

I'm using taxonomylist and archives plugin under Deliver theme but there aren't running well.

I change "category" and "tag" taxonomies terms to "categoría" and "Etiqueta" but, with these, neither "taxonomy list" and "archives" show any results.

(Archives show relates page in blog entry list page, but adding @self filters in conf, but not show in article blog page.)

This is my question: is mandatory to use "category" and "tag"? Doc says that is a suggestion.

I look for something similar in forum, but only encounter a similar thread without solution.

Thanks so much in advance, and sorry for my awful english, is not my mother language.

Best regards.

Salud y Revolución.

Lobo.

9 years ago

They are not required, but if you change them you will probably have to update your plugin configurations for archives plugin as they are defaulting to use category. TaxonomyList should just work though as it will use any filter.

NOTE: You do need to update your taxonomy types in your site.yaml file in order for Grav to know what taxomonies are going to be used: https://learn.getgrav.org/content/taxonomy

9 years ago

Hi @rhuk,

Thanks so much for your answer.

I view that is right for TaxonomyList, need to modify Deliver template in order to catch «Etiqueta», but I modified archives.yaml and was not running, and is not running still.

Site.yaml was modified too, of course.

I paste mi conf:

Taxonmy part of site.yaml:

YAML
[...]
taxonomies: 
   - categoría
   - Etiqueta
   - category
   - tag

Archives.yaml conf:

YAML
enabled: true
built_in_css: true
date_display_format: 'F Y'
show_count: true
limit: 12
order:
    by: date
    dir: desc
filter_combinator: and
filters:
    - categoría: [diario-e]
    - category: [diario-e]
    - '@self'
taxonomy_names:
    month: archives_month
    year: archives_year

I try to maintain category and tag in conf, but still no success.

Perhaps, should be conf related with some Twig template?

Thanks again.

Kind regards.

Salud y Revolución.

Lobo.

9 years ago

Solved the issue with taxnomies, I modified blog_item.html.twig and taxonomylist.html.twig templates in Deliver theme.

But, I test (for test) with sidebar.html.twig template in plugin and Grav catch a Twig_error_runtime.

Copying plugin template to partial code in sidebar.html.twig, Grav fails with:

TWIG
/opt/bitnami/apache/htdocs/user/themes/deliver/templates/partials/sidebar.html.twig

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.</p>
</div>
{# Empezamos pruebas con el complemento de taxnomias #}
{% if config.plugins.taxonomylist.enabled %}
<div class="sidebar-content">
    <h4>Etiquetas populares</h4>
    {% set taxlist = taxonomylist.get() %}

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

</div>
{% endif %}
{% if config.plugins.archives.enabled %}
<div class="sidebar-content">
    <h4>Archives</h4>

              Arguments

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

Fail is for for loop.

I say only for if there are a bug on taxonomylist plugin or wathever, how I say I can solve issue with taxonomy.

Continue in order to solve archives issue.

Thanks.

Regards.

Salud y Revolución.

Lobo.

last edited 09/11/17 by Rubén Gómez Antolí
9 years ago

Copying plugin template to partial code in sidebar.html.twig, Grav fails with:

So sorry, I modify, again, taxonomylist.html.twig file in Deliver theme and, now, included these code from TaxonomyList plugin and runs well.

Perhaps, only fail when is used in sidebar because is different type of output.

Sorry again, how I say before I'm not a programmer and only have some basic skills of it.

Still fighting with Archives sidebar.

Salud y Revolución.

Lobo.

9 years ago

I can solve issue with Archives too, but not in proper way.

If I change in archives.yaml file in plugin directory, archives runs, is taking my user/conf/plugins/archives.yaml conf but seems that don't apply.

Differents from debug info.

Modified user/plugin/archives/archives.yamlfile:

JS
archives

    array:9 [
      "enabled" => true
      "built_in_css" => true
      "date_display_format" => "F Y"
      "show_count" => true
      "limit" => 12
      "order" => array:2 [
        "by" => "date"
        "dir" => "desc"
      ]
      "filter_combinator" => "and"
      "filters" => array:2 [
        "categoría" => "diario-e"
        0 => array:1 [
          "categoría" => array:1 [
            0 => "diario-e"
          ]
        ]
      ]
      "taxonomy_names" => array:2 [
        "month" => "archives_month"
        "year" => "archives_year"
      ]
    ]

Without modifying user/plugin/archives/archives.yamlfile:

JS
archives

    array:9 [
      "enabled" => true
      "built_in_css" => true
      "date_display_format" => "F Y"
      "show_count" => true
      "limit" => 12
      "order" => array:2 [
        "by" => "date"
        "dir" => "desc"
      ]
      "filter_combinator" => "and"
      "filters" => array:2 [
        "category" => "blog"
        0 => array:1 [
          "categoría" => array:1 [
            0 => "diario-e"
          ]
        ]
      ]
      "taxonomy_names" => array:2 [
        "month" => "archives_month"
        "year" => "archives_year"
      ]
    ]

Modify consist only in change filters section from:

YAML
filters:
    category: blog

to:

TXT
filters:
    categoría: diario-e

Is the same behaviour that I obtain from comments plugin.

So, it's possible that any conf says Grav to get this behaviour?

Thanks.

Best regards.

Salud y Revolución.

Lobo.

<strong>Updated</strong>: Fixed archives.yaml change, error with cut and copy.

last edited 09/13/17 by Rubén Gómez Antolí

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 91 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 451 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 45 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 125 3 months ago