we will see every code block of the library and discuss them seperately. At first we have defined our necessary variables.
#ci instance public $ci; #layout variable public $layout;
In the constructor function we have created an instance of codeigniter. the argument of the function gets the filename of our main codeigniter library.
/** * Constructor * * @author Tahsin HasanLet's see the code block of the function that handles the block replacement of our layout. we are passing here three arguments: blocks array contains key-value relationship of block and their corresponding replacement code chunk. view is the filename of the main body content area.* @return void * @param layout String layout file name * @access public */ public function __construct($layout = "layout_main") { $this->ci =& get_instance(); $this->layout = $layout; }
/** * shows our blocks in the layout section * * @author Tahsin Hasan* @return void * @param blocks Array blocks to replace * @param view String code to replace with * @param data Array the data we need to pass * @access public */ public function view($blocks, $view, $data) { $layout = $this->layout; $data['content_for_layout'] = $this->ci->load->view($view, $data, true); $view = $this->ci->load->view($layout, $data, true); foreach($blocks as $key=>$val) { if(empty($val)) { $replaces[$key] = ''; } else { $replaces[$key] = $this->ci->load->view ( $val, NULL, TRUE ); } } $view = str_replace(array_keys($replaces), array_values($replaces), $view); $this->ci->load->view ( 'view', array ('view' => $view) ); }
The content_for_layout variable contains the main body section of a page. We replace this string value with our page specific content. with this page specific content, we then replace the layout with our values and store it in the view file.
Download Advanced Layout library from here.
The block variable contains the other replacements except the main content. we replace each varible with the foreach loop.
the str_replace function done the tricks here. it replaces the keys with the values of the view variable. And finally, we load the view file.
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:
If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.
Wordpress Plugins:
- 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.
- Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.
Opencart Extensions:
- Product Based Quantity Wise Shipping: Find it here.
- OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
- Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
- Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
- Custom Field Product - add unlimited custom fields to the product form: Find it here.
- Formcaptcha - add captcha on the register page: Find it here.
No comments:
Post a Comment