syzygypl / kunstmaan-tag-group-bundle
1.1.0
2016-05-02 09:56 UTC
Requires
- kunstmaan/tagging-bundle: ~3.0
Requires (Dev)
- friendsofsymfony/user-bundle: 2.0.*@dev
This package is not auto-updated.
Last update: 2024-09-14 18:53:09 UTC
README
KunstmaanTagGroupBundle 允许您按组组织标签,并且可以轻松按组和可标记实体过滤标签。
安装
步骤 1: 下载组件
打开命令行界面,进入项目目录,并执行以下命令以下载此组件的最新稳定版本
$ composer require syzygypl/kunstmaan-tag-group-bundle
此命令要求您已全局安装 Composer,如 Composer 文档中的安装章节中所述。
步骤 2: 启用组件
通过将其添加到项目 app/AppKernel.php
文件中注册的组件列表中来启用组件
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Szg\KunstmaanTagGroupBundle\KunstmaanTagGroupBundle(), ); // ... } // ... }
安装资产
app/console assets:install
更新数据库模式
app/console doctrine:schema:update
在 app/config/routing.yml
中添加路由
KunstmaanTagGroupBundle:
resource: "@KunstmaanTagGroupBundle/Resources/config/routing.yml"
用法
- 转到管理员面板
模块/标签组
- 创建具有名称和唯一
internalName
的组 - 将标签添加到组中
- 通过内部名称从组中获取过滤的可标记对象标签
{% set tags = page|tag_group('internalName') %} {% if tags|length %} <ul> {% for tag in tags %} <li>{{ tag.name }}</li> {% endfor %} </ul> {% endif %}
或使用公共服务
<?php $tagGroupService = $this->get('szg_kunstmaantaggroupbundle.tag_group.manager'); $group = $tagGroupService->getGroupByName('internalName'); $tags = $tagGroupService->filterByGroup($taggable, $group)