Action views can be made up of partial views which can make up the template used by a particular action. The syntax for rendering a partial view, within an action view, specifies the location of the file and the associated php file.
Below is the application/views/templates/Example/example.php file which coincidentally is the view used for this page.
<div class="row">
<div class="col-md-9 col-sm-12 col-xs-12">
<h2><?php echo $this->title;?></h2>
<?php $this->renderPartialView("Example", $this->partial);?>
</div>
<div class="col-md-3 col-sm-12 col-xs-12">
<?php $this->renderPartialView("Partial", "_examples");?>
</div>
</div>There is a small bit of magic within the controller action, to load the name of another partial view, which is held in the $this->partial variable.
Below the ExampleController has been shortened for the purposes of this example.
<?php
class ExampleController extends FrontController
{
/**
* URL: Example/viewPartial/
* Alias: partial-view-example/
*
* @return View
*/
public function viewPartialAction()
{
$this->createExampleDisplayTemplate("Partial Views Example", "_viewPartial");
return $this->view();
}
/**
* Creates the necessary settings for an example type file
*
* @param string $title title to load into template
* @param string $partial name of partial view to load into template
* @return void
*/
private function createExampleDisplayTemplate($title, $partial)
{
$this->view->title = $title;
$this->view->partial = $partial;
$this->view->renderer("Example", "example");
}
} /*end of class ExampleController*/Did you know that the menu over to the right of this page is also a partial view?