getgrav / grav-plugin-taxonomylist

Grav TaxonomyList Plugin
https://getgrav.org
MIT License
25 stars 14 forks source link

How to set default values for Taxonomies ? #15

Open fabrizioT opened 7 years ago

fabrizioT commented 7 years ago

Let's suppose i need to add a default value for "tag" or "category" ( or "author" ). How am i supposed to do that ?

beamaria commented 4 years ago

Same question here! How to add a default category to the default route ?

rhukster commented 4 years ago

I"m not sure how this would work? I mean every page in your site gets a default tag? how do you determine what page gets what? Sounds like the job of a custom plugin.

beamaria commented 4 years ago

The plugin I use is the default Taxonomy list by Team Grav. My problem is the plugin accepts only ONE value in "default route" field, but if I have two blogs in my site -"News" and "Features" , both blog_list type, belonging respectively to category News and category Features and both children of "Blog" page. "Blog" (blog_list type) is set to be a multiple collection page using :

`content: items:

        '@taxonomy.category':news
    -
        '@taxonomy.category': features
leading: 0
columns: 2
limit: 4
order:
    by: date
    dir: desc
show_date: false
pagination: true
url_taxonomy_filters: true`

The tags are correctly displayed in "News" or "Features" page and they belong to the correct category, but clicking on any them I have an error 404 - page not found. This is because in the default route of the plugin I can't write: /blog/news or /blog/features. If I write ONE of this routes to categories the links are correctly displayed for THAT category, but there is nothing for the other. I suppose is a problem of base_url . I use helium theme +Gantry 5, with a sidebar custom html particle in which I wrote this code:

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

but of course isn't working, because the base url is not set in the default route of the plugin. I also tried with base url set to absolute in configuration and this messed up all the site (luckily a local one!!) To cut a long story short: is there a system to write a "wild card" for the base _url route in the plugin and in the code which display the results in the front-end? Thanks!

beamaria commented 4 years ago

Ok, found the solution at least for taxonomy list. In my custom_html particle I wrote

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

and this solved the issue!