withcandour/statamic-blog-helpers
Composer 安装命令:
composer require withcandour/statamic-blog-helpers
包简介
Designed to enhance your statamic blog
README 文档
README
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:
composer require withcandour/statamic-blog-helpers
Then publish the publishables from the service provider:
php artisan vendor:publish --provider="WithCandour\StatamicBlogHelpers\ServiceProvider"
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.
{{ blog-helpers-archive:dates collection_name="blog_posts" }}
<option value="{{ value }}" {{ if selected }}selected{{ /if }}>{{ nice }}</option>
{{ /blog-helpers-archive:dates }}
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.
'archives' => [ [ 'uri' => '/blog', 'view' => 'blog.archive', 'layout' => 'layout', 'title_prefix' => 'Posts from' ], ]
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:
{{ collection:blog_posts query_scope="blog_helpers_archive_scope" archive_year="2019" archive_month="03" }}
<!-- Content -->
{{ /collection:blog_posts }}
The year and month variables will get passed to the template that gets rendered for the archive pages so you could simply use:
{{ collection:blog_posts query_scope="blog_helpers_archive_scope" :archive_year="year" :archive_month="month" }}
<!-- Content -->
{{ /collection:blog_posts }}
withcandour/statamic-blog-helpers 适用场景与选型建议
withcandour/statamic-blog-helpers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.63k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 withcandour/statamic-blog-helpers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 withcandour/statamic-blog-helpers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2021-02-17