简体   繁体   English

在Codeigniter中具有段的奇怪功能

[英]Strange functioning with segments in codeigniter

I am currently working on a system with a particular architecture (not mine). 我目前正在使用具有特定体系结构(不是我的体系结构)的系统。 In the main application folder, there is the common asset and 2 others folders (user and admin) with the same kind of asset, which give us this architecture : 在主应用程序文件夹中,有一个共同的资产和另外两个具有相同资产的文件夹(用户和admin),这为我们提供了这种架构:

  • application 应用
    • admin 管理
      • config 配置
      • controller 调节器
      • etc ... 等...
    • user 用户
      • config 配置
      • controller 调节器
      • etc ... 等...
    • controller 调节器
    • etc ... 等...

In the root folder, there is 2 files : user.php and admin.php each having the same code than in the classical index.php except for the line 在根文件夹中,有2个文件: user.phpadmin.php具有与经典index.php相同的代码,但该行除外

$application_folder = 'application/admin';

So far, the code is working... But I have found a strange reaction. 到目前为止,代码正在运行...但是我发现了一个奇怪的反应。 In my folder admin , under a controller, I am calling a method, which work except for one thing... the view are not correctly loaded. 在我的文件夹admin ,在控制器下,我正在调用一个方法,该方法除了一件事情外都可以工作...视图未正确加载。

In all other method I have this kind of code, with only one parameters : 在所有其他方法中,我都有这种代码,只有一个参数:

public function results($param){
  $data = [];

  //some other code

  $this->load->view("election/header");
  $this->load->view("election/menu");
  $this->load->view("election/results", $data);
  $this->load->view("election/footer");
}

This is perfectly working, but when I had a second parameter, miraculously, the method didn't display anymore the header/menu/footer. 这是完美的工作方式,但是奇迹般地,当我有了第二个参数时,该方法不再显示页眉/菜单/页脚。 Only the custom view result ... I also found that if I randomly add another parameter to the previews method results for exemple, the same kind of bug happens. 仅自定义视图result ...我还发现,如果我在示例的预览方法results随机添加另一个参数, results发生相同类型的错误。 The header/footer/menu aren't normally displayed anymore. 页眉/页脚/菜单通常不再显示。 I guess there is a problem with the routing/htaccess or segment... but I can't put my finger on it... 我想路由/ htaccess或网段有问题...但是我不能指望...

Here is the root .htaccess file 这是根.htaccess文件

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^kanri(/(.*))?$ admin.php?/$2 [L]

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

And the admin/routing.php admin/routing.php

$route['default_controller'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

Thanks for your time! 谢谢你的时间!

Thanks to D. Dimitrov, the solution was simple. 感谢D. Dimitrov,解决方案很简单。 I just had to replace the relative path by using the site_url() function. 我只需要使用site_url()函数来替换相对路径。 I haven't totally understand the why but since it's working, it's all gud :> 我还不完全明白为什么,但是既然可以了,那就全是傻瓜了:>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM