Download the PHP package icap-lyon1/simple-tag-bundle without Composer
On this page you can find all versions of the php package icap-lyon1/simple-tag-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download icap-lyon1/simple-tag-bundle
More information about icap-lyon1/simple-tag-bundle
Files in icap-lyon1/simple-tag-bundle
Package simple-tag-bundle
Short Description Symfony TagBundle that easily adds tags to any entity
License GPL-3.0+
Informations about the package simple-tag-bundle
SimpleTagBundle
Symfony2 bundle to easily manage tags with any entity.
Installation
To install this bundle please follow the next steps:
First add the dependency in your composer.json
file:
Then install the bundle with the command:
Enable the bundle in your application kernel:
Then update your database schema:
Then install the bundle assets:
Finally include the bundle configuration file in your app configuration file:
Now the Bundle is installed.
How to use
In order to add tags to an entity, the entity has to implements TaggableInterface example:
Then when you wish to associate an entity with a tag, simply call the icaplyon1_simpletag.manager
service to create a form and process it as explained below:
To save and associate the tags with your entity, call the processForm function like this:
The processForm($form)
method will retrieve the input tags, add new (not already associated) tags and remove associated tags that are not included in the input list
Functions of icaplyon1_simpletag.manager
Associate tags
if you want to associate a tag with your entity:
if you want to associate multiple tags with your entity:
Dissociate tags
if you want to dissociate a tag from your entity:
if you want to dissociate multiple tags from your entity:
Remove all tags from an entity
if you want to remove all tags from your entity (DO THIS WHEN YOU ARE DELETING YOUR ENTITY IN ORDER TO AVOID KEEPING RUBBISH IN YOUR DATABASE):
example in method:
Get tags
In your manager (php)
To get all tags for your entity:
In a twig template
To get the tags associated to an object a twig extension has been created, use it as follows:
Get all stored tags
You can get all stored tags to use them for example for autocomplete
Using php
Using twig
All versions of simple-tag-bundle with dependencies
symfony/framework-bundle Version >=2.1,<2.3-dev
twig/twig Version *
doctrine/doctrine-bundle Version *