getgrav / grav-plugin-archives

Grav Archives Plugin
https://getgrav.org
MIT License
8 stars 12 forks source link

Missing blog_list route from links #18

Open phideas opened 7 years ago

phideas commented 7 years ago

I did setup 2 separate blogs on site using 2 blog_list pages. Archive plugin missing the blog_list page route in links to archived pages. I solved this with a quick hack. Please check it out.

Added new variable "route" in user/plugins/archives/archives.php

            if ($new_approach) {
                 $collection = $page->children();
+                $this->grav['twig']->twig_vars['route'] = $page->route();
            } else {

Added "route" in user/plugins/archives/templates/partials/archives.html.twig

        <a href="{{ base_url }}{{ route }}/{{ config.plugins.archives.taxonomy_names.month }}{{ config.system.param_sep }}{{ month|date('M_Y')|lower|e('url') }}">
kenton-r commented 6 years ago

This can also be added with the following in the partial templates: {% include 'partials/archives.html.twig' with {base_url:base_url ~ page.url} %}

This adds the link to route to the same page (blog) that you are on.

hkockerbeck commented 5 years ago

As a short remark, if you're using multiple languages, you need to use another variable, because both base_url and page.url contain the language code. With base_url:base_url ~ page.url, you'll end up with something like https://your-site.tld/en/en/blog/archives_month:aug_2019, which will lead to a 404 error. The theme variable base_url_simplecontains the base url without the language code. So you can just use base_url:base_url_simple ~ page.url.