public
Description: Cakephp Cycle helper like the rails cycle command
Homepage: http://markgandolfo.com.au
Clone URL: git://github.com/markgandolfo/cakephp_cycle_css.git
nathanaelkane (author)
Sun Oct 11 05:48:05 -0700 2009
markgandolfo (committer)
Sun Oct 11 16:20:29 -0700 2009
name age message
file .gitignore Loading commit data...
file README.markdown
directory views/
README.markdown

CakePHP Cycle Helper Plugin

This plugin provides an easy way to include Mark Gandolfo's Cycle CSS Helper in your CakePHP application.

Installation

Add as a git submodule

git submodule add git://github.com/nathanaelkane/cakephp-cycle-helper-plugin.git app/plugins/cycle_helper/

Alternatively, you can manually download the plugin and place the files in /app/plugins/cycle_helper/

Setup in CakePHP

Setup your app_controller.php (eg. /app/app_controller.php)

<?php
class AppController extends Controller {
    public $helpers = array('CycleHelper.Cycle');
}
?>

Use in your view:

<table>
    <? foreach(array(1,2,3) as $item) : ?>
    <tr class="<?= $cycle->css() ?>">
        <td><?= $item ?></td>
       </tr>
    <? endforeach ?>
</table>

Will output:

<table>
    <tr class="odd">
        <td>1</td>
    </tr>
    <tr class="even">
        <td>2</td>
    </tr>
    <tr class="odd">
        <td>3</td>
    </tr>
</table>

Alternatively, you can specify custom class values:

<table>
    <? foreach(array(1,2,3) as $item) : ?>
    <tr <?= $cycle->css(array('foo', 'bar'), true) ?>>
        <td><?= $item ?></td>
    </tr>
    <? endforeach ?>
</table>

Will output:

<table>
    <tr class="foo">
        <td>1</td>
    </tr>
    <tr class="bar">
        <td>2</td>
    </tr>
    <tr class="foo">
        <td>3</td>
    </tr>
</table>