2017 © Pedro Peláez
 

cakephp-plugin partials

A CakePHP Partial Helper

image

joeytrapp/partials

A CakePHP Partial Helper

  • Thursday, October 17, 2013
  • by real34
  • Repository
  • 1 Watchers
  • 8 Stars
  • 82 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Partial Helper

Installation

Download the repository into the the Plugin directory, (*1)

cd Plugin
git clone git://github.com:joeytrapp/partials.git Partials

Add the CakePlugin::load() in the application bootstrap.php., (*2)

echo "CakePlugin::load("Partials");" >> Config/bootstrap.php

Load the helper so it will be available in views, (*3)

public $helpers = array("Html", "Form", "Partials.Partial");

Methods

PartialHelper::render(string $name, array $data, array $options)

Renders an element relative to the View::viewPath instead of View/Elements. Assumes the element file begins with an underscore., (*4)

<?php echo $this->Partial->render("form"); ?>

Will look for _form.ctp in the View::viewPath (for /posts/add it would be View/Posts/_form.ctp)., (*5)

The $data and $options params are passed on to View::element() method. An additional option is "collection". If "collection" is an array, then the View::element() will be called for each iteration of the "collection" array. The value of the current iteration is merged in the data array under the element name (without the underscore) key., (*6)

<?php echo $this->Partial->render("post", array(), array("collection" => $posts)); ?>

This will render the _post.ctp element for each value in $posts, and set a the value in $posts for this iteration to the "post" key in the data array., (*7)

The Versions

17/10 2013

dev-master

9999999-dev

A CakePHP Partial Helper

  Sources   Download

The Requires

 

cakephp helper partial