felixge / debuggable-scraps
- Source
- Commits
- Network (10)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
3fbfca1
commit 3fbfca1bd3205e78aac80414bb8e8556a40496ae
tree c1401d9d8598bd57ec310b1b608d394606ccc2ed
parent 70ca21000c1309128ef9e5b63b704761dc619f7b
tree c1401d9d8598bd57ec310b1b608d394606ccc2ed
parent 70ca21000c1309128ef9e5b63b704761dc619f7b
| name | age | message | |
|---|---|---|---|
| .. | |||
| |
cloud.php | Wed Sep 24 00:48:16 -0700 2008 | |
| |
readme.textile | Fri Sep 05 05:21:53 -0700 2008 |
cakephp/behaviors/cloud/readme.textile
CakePHP Cloud Behavior
A CakePHP behavior to retrieve a set of records ready for display in a tag-cloud kind of view.
Installing
1. Copy cloud.php to app/models/behaviors/
2. Find the model you intend to use this with and add a configuration similar to this to it:
class AppModel extends Model{
var $actsAs = array('Cloud' => array(
'countField' => 'count',
'query' => array('limit' => 50, 'contain' => false, 'order' => array('Tag.count' => 'DESC')),
));
}
Usage / Docs
To display the records you are interested in as a cloud, all you need to do is query them inside your controller:
$tags = $this->Tag->find('cloud');
$this->set(compact('tags'));
And render them in your view similar to this:
<h3>Tag Cloud</h3>
<?php
$out = array();
foreach ($tags as $tag) {
$size = 10 * $tag['Tag']['scale'];
$out[] = $html->link(
$tag['Tag']['name'],
array('controller' => 'tags', 'action' => 'view', $tag['Tag']['id']),
array('style' => 'font-size: '.$size.'px;')
);
}
echo join(', ', $out);
?>
Known Bugs
None
