CI Framework Integration Widget (page layout) method, Ciwidget
This article describes the CI Framework Integration Widget (page layout) approach. Share to everyone for your reference, as follows:
In the Web development process, we have to export the view file, and generally the view file is usually the head, the left column and the bottom of these common elements.
How to get the whole project to introduce agile thinking and improve efficiency when it comes to applying views? You have to mention the widget. You can also use the HMVC model.
Here's how the widget is incorporated into the CI framework:
1. Add the calling method in the class file my_controller.php:
/** if $name exists, call the Widget class and widget method * @param string $name */protected function widget ($name = ") { if (isset ($name) & & $name! = ") { require_once base_widget. $name. php '; }}
2. Define the Widget class file:
The <?php/*------------widget.php component contains its own controller, view, model (can share common model) * to achieve the common part of each page @author Crystal 20120106------------ --*/class Widget extends my_controller{ private Function __construct () { parent::my_controller (); } /*** gets the current class name * /private static function _getclass () { return __class__; } public static function left () { $class = Self::_getclass (); $data [' userinfo '] = My_controller::_getusercookieinfo (); $this->load->view (' com/left.php ', $data); }}? >
3. Called in the View file (the Widget method in the parent class control should be called first in the corresponding controller):
<?php widget::left ();? A..
More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP Excellent Development Framework Summary", "thinkphp Getting Started", " Summary of common methods of thinkphp, "Introduction to Zend Framework Frame", "Introduction to PHP Object-oriented Programming", "Introduction to Php+mysql Database Operation" and "PHP common database Operation Skills Summary"
It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.
http://www.bkjia.com/PHPjc/1127870.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127870.html techarticle CI Framework Integration Widget (page layout) method, Ciwidget This article describes the CI Framework Integration Widget (page layout) method. Share to everyone for your reference, as follows: In Web development ...