dongsou3041 2014-12-02 01:59
浏览 41

如何在codeigniter中制作Frontend_controller?

I want to create frontend_controller extend from My_controller and then extend from CI_controller as below code

In Configure I created __autoload function for calling class name and file

function __autoload($classname) {
    if (strpos($classname, 'CI_') !== 0) {
        $file = APPPATH . 'libraries/' . $classname . '.php';
        if (file_exists($file)) {
            @include_once($file);
        }
    }
}

Here is for wellcome pages

 class welcome extends Frontend_controler {

    public function __construct(){
        parent::__construct();

    }

    public function index()
    {
        $this->load->view('welcome_message');
    }

}

This is Frontend_controller

<?php
class Frontend_controler extends My_controler{

    public function __construct(){
        parent::__construct();
    }
}
?>

This is My_controller

<?php
class My_controler extends CI_Controller{

    public function __construct(){
        parent::__construct();
    }
}

And the finally I create .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /test/

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>

    ErrorDocument 404 /index.php
</IfModule>

I got only blank pages (white empty pages) when I load my website

What I am wrong with this code?

PLease help thanks advance!!!

  • 写回答

1条回答 默认 最新

  • dongqiang8683 2014-12-03 02:49
    关注

    Here is the solution for my Froentend_Controller and MY_Controller I've change my as bellow so it will work on linux hosting 1, Renamed: file Frontend_controller to : Frontend_Controller 2, Renamed: file Admin_controller to : Admin_Controller NOTES: We have to remember that C first character of your file name and your class in your file name have to capital letter as above centanc. And When we Extends for other Controller we have to call keep good format as will

    Example: MY_Controller.php

     Class Pages extends Frontend_Controller{
           public function __contruct(){
           parent::__construct();
    }
    }
    

    pages.php {pages controller}

     Class Pages extends Frontend_Controller{
           public function __contruct(){
           parent::__construct();
    }
    }
    

    Admin

    Class Admin extends Admin_Controller{
          public function __contruct(){
               parent::__construct();
        }
    }
    

    NOTE: If you named your file and class named is wrong you will get blank pages (empty pages) when you load your site

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题