File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Taggable
2
+ Taggable is a Plugin for CakePHP 2.x to add tags to a model
3
+
4
+ ## Installation
5
+ 1 . Add the GitHub repository to your CakePHP app's Plugin folder.
6
+ 2 . Add the Plugin to your ` bootstrap.php ` file
7
+ 3 . Using the cake console, create your Tag table by running: ` cd APP_DIRECTORY; cake schema create --plugin=Taggable `
8
+
9
+ ## Usage
10
+ ### Taggable Behavior
11
+ Use the Taggable Behavior for any model that you want to connect to the Taggable tags table:
12
+ ```
13
+ class YourModel extends AppModel {
14
+ public $name = "YourModel";
15
+ public $actsAs = array('Taggable.Taggable');
16
+ }
17
+ ```
18
+ #### Filtering by Tags
19
+ You can filter a model query by tags if the model is using the Taggable behavior by including a "tags" field in your query.
20
+ ```
21
+ $this->find('all', array(
22
+ 'tags' => array('news', 'baseball'),
23
+ ));
24
+ ```
25
+ ### Tag Helper
26
+ Use the Tag Helper to add and display tags in your model. Include the TagHelper in your Controller without any parameters:
27
+ ```
28
+ ...
29
+ public $helpers = array('Taggable.Tag');
30
+ ...
31
+ ```
32
+ #### Adding Tags
33
+ Include ` $this->Tag->input("YourModel"); ` in your form. This will display a form to add new tags and remove existing tags.
34
+ #### Displaying Tags
35
+ ```
36
+ echo $this->Tag->tagList($result["YourModel"]);
37
+ ```
38
+ Including a url in the options will make each tag a link:
39
+ ```
40
+ echo $this->Tag->tagList($result["YourModel"], array(
41
+ 'url' => array(
42
+ 'controller' => 'your_models',
43
+ 'action' => 'index',
44
+ )
45
+ ));
46
+ ```
47
+ Each link will have ` tag:TAG_NAME ` appended to the url.
48
+
49
+ Including the boolean value for ` 'x' ` will add an "X" link to each tag, allowing you to remove them from the current url.
You can’t perform that action at this time.
0 commit comments