Chapters
Views & Layouts
Chapter 5
Introduction
A View represents the output of a controller's action.
The action in which a view represents in based on naming conventions. For example the view for the Article controller's action "show" is located in views/article/show.html.
Using Helpers
To use a helper inside of a view there is no loading of anything required like all things in Madeam. Just type in the name of the helper followed by Help and then the method as seen below.
<?php htmlHelp::link('Hello', 'controller/action/id'); ?>
Layouts
Layouts are base templates for all of your pages. Layouts have special variables like $content_for_layout and $header_for_layout.
$content_for_layout is a place holder for a view.
$header_for_layout is a place holder for things that belong in the HTML's head tags.
Layering Layouts
Madeam allows you to layer layouts on top of one another. This can be very useful if you want to re-use a piece of your design to wrap something else on your web site.
The order that you type out the layouts will determine how they are stacked. Let's look at an example:
<?php $this->layout('body', 'standard'); ?>
In this case we are stacking 2 layouts. The first layout which will wrap our action's view is the "body" layout. Once the view's action has been wrapped by the "body" layout everything else is wrapped by the "standard" layout.
Partials
Partials are mini views. -- and this needs more documentation.
<?php echo $this->partial('article/comment', $data); ?>
Previous Chapter Next Chapter