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.

$this->load->library('advancedLayout');

Now we will set our main layout file in it:

$this->advancedlayout->setLayout('path_to_layoutfile');

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


html xmlns="http://www.w3.org/1999/xhtml"
    head
//        stylesheets link will be here.
        
    /head
    body
        {HEADER_LAYOUT}
        
        
{FLASH_MSG_CONT}
{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:

Technical Support:

If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.


Wordpress Plugins:
  1. Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
  2. Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.

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: