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!"?

图片转代码服务由CSDN问答提供 功能建议

我是codeigniter的新手,请原谅我的愚蠢。

我正在建立一个客户端门户,我有我的管理员/客户端登录设置我目前正在管理区域工作,所以我有我的控制器用于管理员设置,它加载存储的视图;

views(文件夹) - &gt; admin(文件夹) - &gt; admin-view.php

我想将所有管理面板视图保存在views文件夹的admin文件夹中。

无论如何我都设置好了 我在管理面板中的页面链接如:

 &lt; a href =“./ admin / company”&gt;客户公司&lt; / a&gt;&lt; br /&gt;  
&lt; a href =“./ admin / client_view”&gt;客户列表&lt; / a&gt;&lt; br /&gt; 
&lt; a href =“./ admin / rig_list”&gt; Rigs / Platforms&lt; / a&gt;  ;&lt; br /&gt; 
   
 
 

现在我明白,当你调用一个url时,我有/ admin /是控制器和/ company /是这个函数 被叫。

现在我想为这个页面调用公司的控制器,因为我在公司控制器中有很多代码,它们定义了为公司提供的视图和数据。 管理面板的页面。

现在我在admin for company中的功能看起来像;

  function company(){
 log_message('debug','  company_view函数Ran'); 
 $ data ['page_title'] ='Bomar客户端门户 - 管理区'; 
 $ this-&gt; load-&gt; view('admin / header',$ data);  
 $ this-&gt; load-&gt; view('admin / admin_navigation');  
 $ this-&gt; load-&gt; view('admin / company_view',$ data);  
 $ this-&gt; load-&gt; view('admin / footer');  
} 
   
 
 

我想替换它来调用公司控制器,我已经调查了类似的问题,从控制器调用控制器,每个人都建议反对它。

因此,如果我不应该从管理员控制器调用公司的控制器,我将如何保持网址指向/ admin / company /

我知道我可以很容易地指向/ company /它会使用公司的控制器呈现页面但是如果你了解我来自哪里,我想将管理位保留在URL中? 这是一个“你做不到这么挑剔!”的案例?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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

    点赞 打赏 评论

相关推荐 更多相似问题