dqf42223 2013-05-07 12:35
浏览 40
已采纳

用于子页面的Codeigniter控制器? (Codeigniter新手请帮忙)

I am new to codeigniter so please excuse my stupidity.

I am building a client portal and I have my admin / client login setup I am currently working on the admin area first so I have my controller for admin setup and it loads a view stored;

views (folder) -> admin (folder) -> admin-view.php

I wanted to keep all my admin panel views in the folder admin within the views folder.

Anyway so I have setup my links to pages in the admin panel like;

    <a href="./admin/company">Client Companies</a><br/>
    <a href="./admin/client_view">Client List</a><br/>
    <a href="./admin/rig_list">Rigs / Platforms</a><br/>

Now I understand that when you call a url like I have /admin/ is the controller and /company/ is the function which is called.

Now I would like to call a controller for company for this page because I have a lot of code in the company controller which defines what views and what data to pull for the company page of the admin panel.

Right now my function in admin for company looks like;

function company(){
    log_message('debug', 'company_view Function Ran');
    $data['page_title'] = 'Bomar Client Portal - Admin Area';
    $this->load->view('admin/header', $data);   
    $this->load->view('admin/admin_navigation');    
    $this->load->view('admin/company_view', $data); 
    $this->load->view('admin/footer');  
}

which I would like to replace just to call the company controller, I have looked into similar questions for calling controllers from controllers and everyone recommends against it.

So if I shouldn't call the controller for company from the admin controller how would I keep the url to point to /admin/company/

I know I could easily point to /company/ and it would render the page using the controller for company but I would like to keep the admin bit in the url if you understand where im coming from? is this a case of "you can't do it stop being so picky!"?

  • 写回答

1条回答 默认 最新

  • dswmmvrg40957 2013-05-07 12:46
    关注

    read up on codeigniter URI routing here:

    http://ellislab.com/codeigniter/user-guide/general/routing.html

    allows you to set up redirects to other controllers

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题