Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Working on the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Mar 9, 2014
1 parent 0adcd5d commit 3592c6d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Docs/Documentation/Overview.md
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.
2 changes: 2 additions & 0 deletions Docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
33 changes: 33 additions & 0 deletions Docs/Tutorials/Find-Tagged-Objects.md
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)));
}
```
26 changes: 26 additions & 0 deletions Docs/Tutorials/Manage-Tags.md
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.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 3592c6d

Please sign in to comment.