dqb78642 2013-05-11 07:56
浏览 49
已采纳

将所有codeigniter函数包含到位于根文件夹中的新静态页面(php文件)[关闭]

I am developing a website which having many static pages. so i created controller only for dynamic pages(it might be wrong practice). Keeping all other static files in root folder. Now i want to use base_url() function from codeigniter for the static pages which is located in root folder. But i am not sure im am doing good practice or not. so ** Please give me a solution to manage many static page in codeigniter. **

  • 写回答

2条回答 默认 最新

  • duanli0453 2013-05-11 10:02
    关注

    you can create a controller with name Static_page send all your static pages requests to this controller

    Static controller

    class Static_Page extends CI_Controller{
    
    
        function index(){
           $page = $this->uri->segment(1,'default_static_page');
           if (!file_exists(APPPATH."views/{$page}.php"))
             {
               show_404();
             } 
           $this->load->view($page);
       }
    
    }
    

    save all your static pages as views with same name as uri you will call like if you call http://your-site.com/about-us your view will be about-us.php, http://your-site.com/contact your view will be contact.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧