https://github.com/sliker/cakephp-counter-plugin
Counter Plugin for CakePHP
https://github.com/sliker/cakephp-counter-plugin
Last synced: about 2 months ago
JSON representation
Counter Plugin for CakePHP
- Host: GitHub
- URL: https://github.com/sliker/cakephp-counter-plugin
- Owner: sliker
- Created: 2012-08-14T19:53:46.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-08-14T20:22:16.000Z (over 12 years ago)
- Last Synced: 2025-01-21T17:50:58.814Z (3 months ago)
- Language: PHP
- Homepage: Counter Plugin for CakePHP.
- Size: 103 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
The Count Plugin provides count functions for CakePHP.
/*
* Count Plugin for CakePHP 2
*
* PHP version 5
*
* @copyright Copyright 2010, Cake. (http://trpgtools-onweb.sourceforge.jp/)
* @category README
* @package Count Plugin
* @version 0.1
* @author Cake
* @update David
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @link https://github.com/Cake/CakePHP-Counter-Plugin
*/## Requirements ##
* PHP version: PHP 5.2+
* CakePHP version: 2.x## Functions ##
+Behavior
-Countup
- saveCount([$foreign_key])
save a count.
$foreign_key : The unique id of model.-getTotalCount([$foreign_key, $conditions])
get total counts by he model (and the foreign_key).
$foreign_key : The unique id of model.
$conditions : Optional conditions to get total counts. The format is same as $model->find().+Helper
-Count
- totalCount($data[, $options])
Output total count.
$data : data type array('Count' => array(...)).
$options : array type.
$options['tag'] sets the type of tag. Default is span.
other parameters are the HTML attributes(id, class and so on).#Installation
Create table by schema.
====
cake schema create counts -plugin count( -dry)
====
Add Countup Behavoir at the model.
====
var $actsAs = array(
'Count.CountUp',
);====
Call saveCount() to count up.
====
(Example: At controllers)
$this->[Modelname]->saveCount($id);
====
The total count can be displayed by the Count helper.
====
(Example: At controllers)
var $helpers = array(
'Html',
'Count.Count',
);(At view)
echo $count->totalCount($link, array(
'tag' => 'div',
'id' => 'total_count',
'class' => 'link',
));====