From 3592c6d4cf160154934aeff1dabd373d6cef3dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sun, 9 Mar 2014 19:31:32 +0100 Subject: [PATCH] Working on the documentation --- Docs/Documentation/Overview.md | 4 ++-- Docs/Home.md | 2 ++ Docs/Tutorials/Find-Tagged-Objects.md | 33 +++++++++++++++++++++++++++ Docs/Tutorials/Manage-Tags.md | 26 +++++++++++++++++++++ readme.md | 4 ++-- 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 Docs/Tutorials/Find-Tagged-Objects.md create mode 100644 Docs/Tutorials/Manage-Tags.md diff --git a/Docs/Documentation/Overview.md b/Docs/Documentation/Overview.md index ff19a78..20760a6 100644 --- a/Docs/Documentation/Overview.md +++ b/Docs/Documentation/Overview.md @@ -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. \ No newline at end of file +It saves all tags in a sginle tags table and connects any kind of records to them through the tagged table. \ No newline at end of file diff --git a/Docs/Home.md b/Docs/Home.md index abe259d..171828f 100644 --- a/Docs/Home.md +++ b/Docs/Home.md @@ -23,3 +23,5 @@ Tutorials --------- * [Quick Start](Tutorials/Quick-Start.md) +* [Find Tagged Objects](Tutorials/Find-Tagged-Objects.md) +* [Manage Tags](Tutorials/Manage-Tags.md) diff --git a/Docs/Tutorials/Find-Tagged-Objects.md b/Docs/Tutorials/Find-Tagged-Objects.md new file mode 100644 index 0000000..4145452 --- /dev/null +++ b/Docs/Tutorials/Find-Tagged-Objects.md @@ -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))); +} +``` \ No newline at end of file diff --git a/Docs/Tutorials/Manage-Tags.md b/Docs/Tutorials/Manage-Tags.md new file mode 100644 index 0000000..712743b --- /dev/null +++ b/Docs/Tutorials/Manage-Tags.md @@ -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. \ No newline at end of file diff --git a/readme.md b/readme.md index 44c8c5b..435991a 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,9 @@ Tags Plugin for CakePHP ======================= -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. [![Bake Status](https://secure.travis-ci.org/CakeDC/tags.png?branch=master)](http://travis-ci.org/CakeDC/tags) [![Test Coverage](https://coveralls.io/repos/CakeDC/tags/badge.png?branch=master)](https://coveralls.io/r/CakeDC/tags?branch=master)