This repository has been archived by the owner on May 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
101 lines (62 loc) · 2.31 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
WARNING!
---------
USE ONLY ON FRESH AKELOS INSTALLATIONS AS IT MIGHT OVERRIDE YOUR EXISTING FILES!!!
Acts as Taggable Plugin
===================================
The Taggable Plugin is inspired by the RoR plugin acts_as_taggable_on_steroids
(http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroids)
The Purpose of the plugin is to easily make any model taggable.
Setting:
class MyModel extends ActiveRecord
{
var $acts_as = 'taggable';
}
allows you to add Tags to the model.
Installation
--------------------------------
./script/plugin install acts_as_taggable
The Installer will add some new methods to the app/shared_model.php.
Please do not modify them, they are marked with
/** AUTOMATED START: get_tags */
function get_tags()
{
.....
}
/** AUTOMATED END: get_tags */
Adding tags to your models
----------------------------------
Simply add the $acts_as = 'taggable' to your model and start adding Tags by:
$model = new MyModel();
$model->addTag('Some tag');
$model->addTags('anothertag','Third tag');
When the model is saved, the tags are also being saved.
Removing tags from your models
----------------------------------
$model->removeTag('Some tag');
will remove the tag "Some tag". After calling $model->save() the tag will be removed from the
database as well.
Retrieving tags from a model
----------------------------------
To retrieve the tags from a taggable model do:
$array = $model->get_tags();
Which will give you the assigned tags as an array.
$tagList = $model->get_tag_list();
will give you back a TagList Object which has a toString() method:
echo $tagList->toString();
--> "Some tag", anothertag, "Third tag"
Finding Objects by tags
----------------------------------
Examples:
$this->Products = $this->Product->findTaggedWith($this->params['tag']);
$this->Products = $this->Product->findTaggedWith('tag1,tag2');
$this->Products = $this->Product->findTaggedWith(array('tag1','tag2'));
Generating a Tag Cloud
------------------------------
Inside your template:
<?php
echo $tagcloud_helper->tag_cloud('Product',null,array('link'=>'/product/tag/:tag'));
?>
Will generate a tag cloud for the Model Product and will link all tags to /product/tag/:tag
Future
--------
See TODO file to know what will be implemented into future versions of this plugin.