duanou9758 2019-06-17 08:53
浏览 37

如何从codeigniter的控制器打开核心php中的视图

I have my php project in following structure

> myProject  
   ->memberList.php  
   ->memberEntry.php  
   ->ci
       ->application
           ->controller             
                ->siteController        
           ->model      
           ->view

I am using both core php and Codeigniter framework for my project named 'myProject.' I have added CI framework inside folder named 'ci'. Most of the code is in core php and for some forms only i have use ci framework. I have to open a form named memberEntry.php from siteController.How can this be done? My controller code is like this:

public function auditDetails(){
    ..........
    $this->load->view('../../../memberEntry', $data);
}
  • 写回答

1条回答 默认 最新

  • dragon8997474 2019-06-17 09:05
    关注

    Assuming this is your structure:

    enter image description here

    go in to index.php and change the following variables

    /*
     *---------------------------------------------------------------
     * SYSTEM DIRECTORY NAME
     *---------------------------------------------------------------
     *
     * This variable must contain the name of your "system" directory.
     * Set the path if it is not in the same directory as this file.
     */
        $system_path = 'ci/system';
    
    /*
     *---------------------------------------------------------------
     * APPLICATION DIRECTORY NAME
     *---------------------------------------------------------------
     *
     * If you want this front controller to use a different "application"
     * directory than the default one you can set its name here. The directory
     * can also be renamed or relocated anywhere on your server. If you do,
     * use an absolute (full) server path.
     * For more info please see the user guide:
     *
     * https://codeigniter.com/user_guide/general/managing_apps.html
     *
     * NO TRAILING SLASH!
     */
        $application_folder = 'ci/application';
    
    /*
     *---------------------------------------------------------------
     * VIEW DIRECTORY NAME
     *---------------------------------------------------------------
     *
     * If you want to move the view directory out of the application
     * directory, set the path to it here. The directory can be renamed
     * and relocated anywhere on your server. If blank, it will default
     * to the standard location inside your application directory.
     * If you do move this, use an absolute (full) server path.
     *
     * NO TRAILING SLASH!
     */
        $view_folder = './';
    

    then you can just load view as normal $this->load->view('welcome_message');


    I would also suggest not using camelCase definitions for files and switch over to Something_more_codeigniter_friendly.php. This is required for controllers.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)