dev-master
9999999-devA CakePHP Partial Helper
The Requires
- php >=5.2.0
- composer/installers *
by Joey Trapp
cakephp helper partial
A CakePHP Partial Helper
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");
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)
A CakePHP Partial Helper
cakephp helper partial