search
HomeBackend DevelopmentPHP TutorialHow to integrate widget (page layout) with CI framework, ciwidget_PHP tutorial

How the CI framework integrates widgets (page layout), ciwidget

This article describes how the CI framework integrates widgets (page layout). Share it with everyone for your reference, the details are as follows:

In the process of WEB development, we inevitably have to output view files, and usually view files generally contain common elements such as the header, left column, and bottom.

How to introduce agile thinking into the entire project development when it comes to view application and improve efficiency? I have to mention widgets. Of course you can also use the HMVC model.

Here we only introduce how widgets are integrated into the CI framework:

1. Add the calling method in the class file MY_Controller.php:

/*
* 如果$name存在则调用widget类及widget方法
*@param string $name
*/
protected function widget ($name = '')
{
    if (isset($name) && $name != '')
    {
      require_once BASE_WIDGET.$name.'.php';
    }
}

2. Define widget class file:

<&#63;php
/*------------
widget.php 组件包含自己的控制器,视图,模型(可以共用普通model)
*用来实现各页面都有的公共部分
@author crystal 20120106
--------------*/
class Widget extends MY_Controller
{
  private function __construct()
  {
    parent::MY_Controller();
  }
  /*** 获取当前类名*/
  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);
  }
}
&#63;>

3. Call in the view file (the widget method in the parent class control should be called first in the corresponding controller):

<!--left sider -->
<div>
<&#63;php Widget::left();&#63;>
</div>
...
<!--/left sider -->

Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php excellent development framework summary", "ThinkPHP introductory tutorial", "Summary of Common Methods in ThinkPHP", "Introduction Tutorial on Zend FrameWork Framework", "Introduction Tutorial on PHP Object-Oriented Programming", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127870.htmlTechArticleHow to integrate widget (page layout) with CI framework, ciwidget This article describes the CI framework integration widget (page layout) with an example method. Share it with everyone for your reference, the details are as follows: Developing in WEB...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php如何使用CI框架?php如何使用CI框架?Jun 01, 2023 am 08:48 AM

随着网络技术的发展,PHP已经成为了Web开发的重要工具之一。而其中一款流行的PHP框架——CodeIgniter(以下简称CI)也得到了越来越多的关注和使用。今天,我们就来看看如何使用CI框架。一、安装CI框架首先,我们需要下载CI框架并安装。在CI的官网(https://codeigniter.com/)上下载最新版本的CI框架压缩包。下载完成后,解压缩

PHP中如何使用CI框架PHP中如何使用CI框架Jun 27, 2023 pm 04:51 PM

PHP是一种流行的编程语言,广泛应用于Web开发。CI(CodeIgniter)框架是PHP中最受欢迎的框架之一,它提供了一整套现成的工具和函数库,以及一些流行的设计模式,让开发人员能够更加高效地开发Web应用程序。本文将介绍使用CI框架开发PHP应用程序的基本步骤和方法。了解CI框架的基本概念和结构在使用CI框架之前,我们需要先了解一些基本的概念和结构。下

php如何使用CI4框架?php如何使用CI4框架?Jun 01, 2023 pm 02:40 PM

PHP是一种广泛使用的服务器端脚本语言,而CodeIgniter4(CI4)是一个流行的PHP框架,它提供了一种快速而优秀的方法来构建Web应用程序。在这篇文章中,我们将通过引导您了解如何使用CI4框架,来使您开始使用此框架来开发出众的Web应用程序。1.下载并安装CI4首先,您需要从官方网站(https://codeigniter.com/downloa

PHP中的CI框架指南PHP中的CI框架指南May 22, 2023 pm 07:10 PM

随着互联网的发展和不断地融入人们的生活,网络应用的开发变得越来越重要。PHP作为一种众所周知的编程语言,已经成为了开发互联网应用程序的首选语言之一。而开发人员们可以使用众多的PHP框架来简化开发过程,其中最受欢迎的之一是CodeIgniter(CI)框架。CI是一个强大的PHPweb应用框架,它拥有轻量级、简单易用、优化性能等特点,可以让开发人员快速地构建

ci框架如何引入cssci框架如何引入cssDec 26, 2023 pm 05:20 PM

CI框架中引入CSS样式的步骤如下:1、准备CSS文件;2、将CSS文件存储在CI框架项目的适当位置;3、在需要使用CSS样式的页面中,通过HTML的<link>标签引入CSS文件;4、在HTML元素中使用CSS类或ID名称来应用相应的样式即可。

详解CI框架中引用CSS样式的步骤详解CI框架中引用CSS样式的步骤Jan 16, 2024 am 09:28 AM

教程:CI框架中引入CSS样式的详细步骤,需要具体代码示例引言:在开发网页应用程序中,样式是至关重要的一部分。使用CSS(层叠样式表)可以美化网页并提供更好的用户体验。而在使用CodeIgniter(CI)框架进行开发时,如何正确引入CSS样式就显得尤为重要。本文将介绍CI框架中引入CSS样式的详细步骤,并为您提供具体的代码示例。步骤一:创建CSS文件首先,

使用CI框架向网页引入CSS样式的步骤使用CI框架向网页引入CSS样式的步骤Jan 16, 2024 am 09:20 AM

CI框架引入CSS样式的步骤,需要具体代码示例CI(CodeIgniter)框架是一种流行的PHP开发框架,被广泛用于构建高效的Web应用程序。在开发Web应用程序时,美观的用户界面是一个重要的考虑因素。使用CSS样式可以达到对Web应用程序界面的优化和个性化,让用户获得更好的体验。在CI框架中,引入CSS样式通常需要以下步骤,并附带具体的代码示例。步骤1:

php如何使用CI6框架?php如何使用CI6框架?Jun 01, 2023 pm 11:10 PM

PHP是一门非常流行的网页开发语言,而CodeIgniter(CI)则是一款非常受欢迎的PHP框架。CodeIgniter提供了很多有用的功能和特性,为开发人员带来了很大的便利。在本文中,我们将探讨如何使用CI6框架。安装CI6在开始使用CI6之前,必须先完成安装过程。您需要首先从CodeIgniter官网下载CI6的压缩包。然后,解压缩这个文件并将其放置在

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!