sunadarake / sculpin-new-posts-list-bundle
第三方Sculpin插件,用于创建新的文章列表
1.0.1
2021-03-13 10:15 UTC
Requires
- php: ^8.0 || ^7.3
- sculpin/sculpin: ^3.1.0
README
第三方Sculpin插件,用于创建新的文章列表
设置
composer require sunadarake/sculpin-new-posts-list-bundle
在你的 app/SculpinKernel.php
文件中
<?php use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel; use Darake\SculpinNewPostsListBundle\SculpinNewPostsListBundle; class SculpinKernel extends AbstractKernel { protected function getAdditionalSculpinBundles(): array { return [ SculpinNewPostsListBundle::class, ]; } }
如何使用
在你的模板文件中,例如 layout/default.html
<ul>
{% for post in site.new_posts %}
<li><a href="{{ site.url }}/{{ post.data.get('url') }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
在默认配置下,你可以显示5篇新的文章。
如果你需要更改要显示的新文章数量,请在 app/config/sculpin_kernel.yml
中配置文章数量。
sculpin_content_types:
posts:
permalink: pretty
sculpin_new_posts_list:
max_per_page: 10