sunadarake / sculpin-category-list-bundle
第三方Sculpin Bundle,用于创建分类列表
1.0.0
2021-03-13 08:30 UTC
Requires
- php: ^8.0 || ^7.3
- sculpin/sculpin: ^3.1.0
README
第三方Sculpin Bundle,用于创建分类列表
设置
composer require sunadarake/sculpin-category-list-bundle
在你的 app/SculpinKernel.php
<?php use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel; use Darake\SculpinCategoryListBundle\SculpinCategoryListBundle; class SculpinKernel extends AbstractKernel { protected function getAdditionalSculpinBundles(): array { return [ SculpinCategoryListBundle::class, ]; } }
如何使用
如果你已经在 app/config/sculpin_kernel.yml
中配置了分类,你可以在模板文件中写入以下内容。
<h2>category list</h2>
<ul>
{% for cat in site.categories_list %}
<li>{{ cat.name }} {{ cat.count }}</li>
{% endfor %}
</ul>
或者
<h2>tag list</h2>
<ul>
{% for tag in site.tags_list %}
<li>{{ tag.name }} {{ tag.count }}</li>
{% endfor %}
</ul>