Elements
An element is essentially a reusable section of a view that can be utilized from any number of different views or layouts.
Access from within a view or layout is:
or
eg:
Within the welcomeMessage element you will have a local variable
Access from within a view or layout is:
$yourElement = get::element('elementName', array $args);
or
load::element('elementName', array $args);
Passing variables into your element
Elements can access the any variable returned by your controller to the view. To add other variables you pass an array of variables to the optional$args
argument and the array items become local variables within the element.eg:
load::element('welcomeMessage', array('fullname' => 'Mr. Sanchez'));
Within the welcomeMessage element you will have a local variable
$fullname
set to Mr. SanchezElement folders
To package multiple elements into a folder you prepend the path, slash-delimited, when you load/get the element:load::element('folderName/elementName');