zoukankan      html  css  js  c++  java
  • 后盾网-CI框架实例教程-马振宇

    第三节视频:

      1、配置自动加载辅助函数URL:

        在application/config/autoload.php中设置:

          $autoload['helper'] = array('url');

      2、配置默认控制器:

        在application/controllers下新建两个文件夹index和admin,用以区分前台和后台的控制器;

        在application/controllers/index/下新建home.php

        在application/config/routes.php里面修改默认的控制器:

          $route[‘default_controller’] = 'welcome';

         修改为:

          $route['default_controller'] = 'index/home';

       此版本为CodeIgniter 2.2.6,CodeIgniter 3.1.6版本不支持以上操作;

      3、载入模板:

        在application/views下新建两个文件夹index和admin,用以分别存放前台模板和后台模板;

        在ci文件夹下新建文件夹style,并在style里面新建两个文件夹index和admin,用以分别存放前台和后台的样式;

        在模板中引用样式时,使用 <?php echo base_url().'style/index/' ?>css/index.css

        <link href="<?php echo base_url().'/style/index/'?>css/index.css" rel="stylesheet" />

      4、如何引入分类页:

        在控制器中载入分类页模板:

        class Home extends CI_Controller{

          // 默认首页显示方法
          public function index(){
            $this ->load ->view('index/index.html');
          }

          // 分类页显示方法
          public function category(){
            $this ->load ->view('index/category.html');
          }
        }

        在首页模板中引入分类页的地址:

          <a href="<?php echo site_url().'/index/home/category'; ?>">青春</a>

      5、如何在分类页中引入文章阅读页:

        在Home 控制器中载入文章阅读页的模板:

          // 文章阅读页显示方法
         public function details(){
          $this ->load ->view('index/details.html');
         }

        在分类页中引入文章阅读页的地址:

          <a href="<?php echo site_url().'/index/home/details'?>" class='more'>更多>></a>

      ===================================

      6、载入后台模板:

        在application/controller/admin下新建控制器admin.php

        在Admin控制器中载入后台首页:

          class Admin extends CI_Controller{

            // 后台首页方法
            public function index(){
              $this ->load ->view('admin/index.html');
            }
          }

        在后台首页中引入后台样式:

          <link rel="stylesheet" href="<?php echo base_url().'style/admin/'?>css/admin.css" />

       7、在后台模板中载入默认欢迎页:(此为iframe)

            //默认欢迎
          public function copy(){
            $this ->load ->view('admin/copy.html');
          }

        在默认欢迎页中引入样式:

          <link rel="stylesheet" href="<?php echo base_url().'style/admin/'?>css/admin.css" />

       8、在application/controller/admin/下新建控制器login.php,用以写入登录方法:

          //后台登录控制器
          class Login extends CI_Controller{
          //登录默认方法
            public function index(){
              $this ->load ->view('admin/login.html');
            }
          }

        在后台登录页面中引入样式:

          <link rel="stylesheet" href="<?php echo base_url().'style/admin/'?>css/login.css" />

          

        

      

  • 相关阅读:
    Importing multi-valued field into Solr from mySQL using Solr Data Import Handler
    VMware Workstation 虚拟机使用无线wifi上网配置
    Linux开发黑客
    GitHub 使用说明
    虹软人脸检测和识别C#
    C#将结构体和指针互转的方法
    笔记本电脑连接wifi,同时提供热点wifi给手机使用
    基于STM32L4的开源NBIOT开发资料
    ESP8266擦除工具完整安装
    开发快平台(M302I小e开发板系列教程)
  • 原文地址:https://www.cnblogs.com/chengshun/p/7634073.html
Copyright © 2011-2022 走看看