I have a frontpage which is modular in nature, but not in setup, meaning that I display posts from specific taxonomies through loops in twig to get the following structure (
- Featured: 3
- Series: 1
- Featured: 3
- News: 18
- Featured: 5
This works well enough when taxonomies are categories, as I can redirect to category-pages like
However, all posts also have tags. Per the usual Grav setup a tag is accessible as
/tag:TAG, but because the frontpage does not use collections this has no effect. Also, even if it did use collections this modular display of posts would not work well with the tag-filtering.
Can I route
/tag:TAG to display a different template? For example, posts tagged with
summer would display as a category-page (which is a template) but without the page-structure set up (the categories all have folders with child pages).
An initial test using:
Yields this error:
[Tue Apr 19 01:03:33.517996 2016] [:error] [pid 2460:tid 1224] [client ::1:57842] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in C:\\Bitnami\\wampstack-7.0.2-1\\apps\\fremmed\\htdocs\\system\\src\\Gr av\\Common\\Page\\Pages.php on line 348
[Tue Apr 19 01:03:33.519998 2016] [:error] [pid 2460:tid 1224] [client ::1:57842] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in C:\\Bitnami\\wampstack-7.0.2-1\\apps\\fremmed\\htdocs\\vendor\\compose r\\ClassLoader.php on line 412
Though I am not quite sure why.
It should redirect from
/tags/tag;sample (using the Windows-separator since I am developing on Windows). Ideally this would allow
/tags/TAG to display any tag, possibly chained by comma-separation from the
Hi @Gingah, routes are not anchored (see my earlier post https://getgrav.org/forum#!/general:redirection-problem ). You need at least
to make it work, otherwise it redirects you to
/tags/tags/tag;mytagand so on yielding the above error.
Hmm, using that route and testing
/tags/readability still yields the error.
Ah, sorry. You are right. You have to exclude any route having the param separator in it. This should solve it:
That excludes the PHP-error, but
/tags/readability now returns a 404 - without any displayed or logged error. I wonder if it might not altogether be easier to do it through .htaccess, so that
/tags/readability is the mask of
There is nothing special about
/tag:something. This is just a Grav parameter that is available on any URL.
You can just change the URL of where you want to filter (by overriding the plugin template, or passing a different
base_url to the partial), and on that page, define your collection that will be filtered by the tag.
That works, and is also how many themes apply the logic. However, rather than filter the collection/content by the tag I have set up a separate template for tags which lists all content with the specified tag, grouped by year and month. What I am trying to achieve is a more user-friendly route for this, ie.
/tags/TAG instead of
This is of course a preference for displaying an archive/listing rather than filtering and paginating content.