CI Framework Integration Widget (page layout) method, ciwidget_php tutorial

Source: Internet
Author: User
Tags codeigniter zend framework

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.