An open API service indexing awesome lists of open source software.

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

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',
));

====