This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florian Krämer
committed
Mar 9, 2014
1 parent
0adcd5d
commit 3592c6d
Showing
5 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Overview | ||
======== | ||
|
||
The tags plugin includes the Taggable Behavior that allows you to simply tag everything. | ||
The **Tags** plugin includes the TaggableBehavior that allows you to simply tag everything. | ||
|
||
It saves all tags in a tags table and connects any kind of records to them through the tagged table. | ||
It saves all tags in a sginle tags table and connects any kind of records to them through the tagged table. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Find Tagged Objects | ||
=================== | ||
|
||
The Tagged model has a custom `_findTagged()` method to find or paginate objects tagged with a given tag. | ||
|
||
h2. Find usage examples | ||
|
||
* To find all Articles having at least one Tag the call would be: `$this->Tagged->find('tagged', array('model' => 'Article'));` | ||
* To find all Articles tagged _cakephp_ the call would be: `$this->Tagged->find('tagged', array('by' => 'cakephp', 'model' => 'Article'));` | ||
|
||
Pagination usage example | ||
------------------------ | ||
|
||
You can also use this custom find method with paginated results. It is expected that you know how CakePHPs Model::find() and costum find methods work. | ||
|
||
Below is a complete example of using the `_findTagged` method with pagination to filter elements by tag: | ||
|
||
```php | ||
public function index() { | ||
if (isset($this->passedArgs['by'])) { | ||
$this->paginate['Tagged'] = array( | ||
'tagged', | ||
'model' => 'Recipe', | ||
'by' => $this->passedArgs['by']); | ||
$recipes = $this->paginate('Tagged'); | ||
} else { | ||
$this->Recipe->recursive = 1; | ||
$recipes = $this->paginate(); | ||
} | ||
$this->set('recipes', $recipes); | ||
$this->set('tags', $this->Recipe->Tagged->find('cloud', array('limit' => 10))); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Manage tags | ||
=========== | ||
|
||
The **Tags** plugin is shipped with a TagsController allowing the administrator to perform generic administrative tasks on Tags. | ||
|
||
To link these actions, use a classic CakePHP array formatted url: | ||
|
||
```php | ||
echo $this->Html->link(__('List Tags'), array( | ||
'plugin' => 'tags', | ||
'controller' => 'tags', | ||
'action' => 'index | ||
)); | ||
``` | ||
|
||
The available actions are: | ||
|
||
* index(), | ||
* view($keyName = null), | ||
* admin_index(), | ||
* admin_view($keyName), | ||
* admin_add(), | ||
* admin_edit($tagId = null), | ||
* admin_delete($id = null) | ||
|
||
Note: rename these method names if you use a different admin prefix. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters