Wednesday, July 14, 2010

How to use Advanced layout library

We have seen the documentation. Now let's see how we can use the library. At first we need to load Advanced Layout Library for codeigniter.


Now we will set our main layout file in it:


We have put our main layout file in the view file. The file is like this:

html xmlns=""
//        stylesheets link will be here.
{FOOTER_LAYOUT} /body /html

Here, you can see we have set some variable which will be replaced with our layout values. We can have here as many replacement block as we like. we have set header, top navigation, flash message, body and footer. Not necessary that we also need to implement all those blocks. just use as you like the blocks to be.

In the controller, from which the page is called, we need to replace our layout variables there. the following code does the trick:

$this->advancedlayout->view(array ('{HEADER_LAYOUT}' => 'common/header','{TOP_LAYOUT}'=>'', '{FLASH_MSG_CONT}' => 'common/flash_msg_cont', '{FOOTER_LAYOUT}' => 'common/footer' ),$viewName, $this->_data);

Here, you can see that each variables is set as key and there is a corresponding files in he view file. so, we just write the location of the specific view file. then the variable is replaced with our code.

we set multiple blocks even the main content block. just check the following code block.

echo $admin_right_column;

we are echoing a variable, this can be any variable that we set in the controller. now we need to write the following the controller:

$this->_data['admin_right_column'] = $this->load->view('common/admin_right',$this->_data, TRUE);

Here, the variable contains the content of the admin right column.

And finally, you need to have a view file named 'view' in our main view folder. the file will be like this:

echo $view;

Download Advanced Layout library from here.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide

List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

No comments: