Quick Start Guide
Download the library and add the files to your application folder, the quick start guide assumes you have all the files in place and correct folder structure. Check out folder structure for more info on file and folder locations.
Load the library from within your controller using the CodeIgniter load method:
You can also load the library from within your autoload file, the autoload file can be found within the application config folder.
Create your theme folder within your flexi folder (The download comes with an example theme) and add a template file to the new theme folder (the example also contains an example template file). Template files are the different page designs/layouts so for a page template make a page.php file or for a homepage make a homepage.php file.
Inside your template file you should place at least the getContent() method which will get and output the requested page content:
<?= $this->Flexi->getContent() ?>
The theme and template properties must be set for the library to be able to select the correct files. You can set the theme name and template name from within your config file or from inside controller. Set the properties in your controller like so:
//The theme file $this->Flexi->theme('example'); //The layout template $this->Flexi->template('template_page_example');
All of the prerequisites should now be set so we can load the actual content, content files are stored in the view folder outside of the theme folder. Load the view as below, you can also pass variables into the second parameter just like loading a normal view:
$data = array( 'variable' => 'some variables' ); $this->Flexi->make('home', $data);
Your variable can be accessed by calling the variable inside your content view file:
<?= $variable ?>
Thats the basics to the Flexi layout library but we have only just scratched the surface, checkout the rest of the guide for more on partials, setting config items and template methods or visit the API for a list of all the available methods.