Download the PHP package withcandour/statamic-blog-helpers without Composer
On this page you can find all versions of the php package withcandour/statamic-blog-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download withcandour/statamic-blog-helpers
More information about withcandour/statamic-blog-helpers
Files in withcandour/statamic-blog-helpers
Package statamic-blog-helpers
Short Description Designed to enhance your statamic blog
License
Informations about the package statamic-blog-helpers
Statamic Blog Helpers
Designed to enhance your statamic blog, currently this addon adds:
- Routes for archivable content (content which has a
date
) - Tags for generating a list of all possible archive dates in a collection
- A query scope for filtering your collections on the archive routes.
Installation
Install via composer:
Then publish the publishables from the service provider:
Tags
This addon provides a tag for generating the archive dates for a specific Statamic collection.
By default the dates generated will be as follows:
- For any date within the current year, each month for which there is an entry will get pulled through
- Entries that have a date before the start of the current year will be grouped by their year
This example will generate a select option for each archive date.
Archives and Routing
By default the archive routes follow the pattern: /{uri}/archive/{year}/{?month}
Once installed a config/statamic/blog-helpers.php
file will be created. In this file you may register your archives, the addon will then generate the routes and handle the rendering of the pages.
In this example an archive will be created for the /blog
page (e.g. blog/archive/2021/01
). It will use the blog.archive
template view and the layout
layout view. The title for this page will also be "Posts from" followed by the archive date.
Filtering
This addon adds the "blog_helpers_archive_scope" query scope which you can use to filter your collection, simply give it an archive_year
and an archive_month
and it will filter the entries returned by your collection tag automatically.
In this example blog_posts
from March 2019 will get pulled through:
The year
and month
variables will get passed to the template that gets rendered for the archive pages so you could simply use: