KunstmaanTagGroupBundle enables you to organize tags in groups and easy filter tags by group and taggable entity.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require syzygypl/kunstmaan-tag-group-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Szg\KunstmaanTagGroupBundle\KunstmaanTagGroupBundle(),
);
// ...
}
// ...
}
Install assets
app/console assets:install
Update database schema
app/console doctrine:schema:update
Add routes in app/config/routing.yml
:
KunstmaanTagGroupBundle:
resource: "@KunstmaanTagGroupBundle/Resources/config/routing.yml"
- Go to admin panel
Modules/Tags Groups
- Create group with name and unique
internalName
- Add tags to groups
- Get filtered taggable object tags from group by internalName:
{% set tags = page|tag_group('internalName') %}
{% if tags|length %}
<ul>
{% for tag in tags %}
<li>{{ tag.name }}</li>
{% endfor %}
</ul>
{% endif %}
or use the public service:
<?php
$tagGroupService = $this->get('szg_kunstmaantaggroupbundle.tag_group.manager');
$group = $tagGroupService->getGroupByName('internalName');
$tags = $tagGroupService->filterByGroup($taggable, $group)