【发布时间】:2013-04-05 06:07:22
【问题描述】:
我正在使用 codeigniter 2.1 并在控制器中加载了分页库。分页工作得很好,唯一的问题是,
我必须添加(用于加载它的控制器中的分页库)
$config['base_url'] = site_url('members/sites/'.$current_segment);
这很好,但它似乎覆盖了默认的 base_url();到该控制器下所有页面中的此 URL。我不想要那个。
我已经包含了一个侧边栏导航,并且所有链接都从类似的东西改变了
http://www.mysite.com/about 至 http://www.mysite.com/members/sites/about
这很烦人。是不是我做错了什么?
我不想添加其他默认 URL,例如
$config['base_url']['one'] = "www.mysite.com"
$config['base_url']['two'] = "www.myothersite.com"
我认为应该有更好的方法来做到这一点。 很感谢任何形式的帮助 :) 提前致谢
【问题讨论】:
-
这个
$config数组用于分页库,而不是application/config/config.php对吧? -
是的,很复杂。无论如何,它似乎仍然覆盖了 application/config/config.php base_url。奇怪...
-
您绝对不需要编辑标题并将它们标记为已解决。
-
CI 有 1 个名为 $config 的配置数组。如果您在 2 个文件中有相同的密钥,除非您将 config::load() 中的第二个参数设置为 TRUE,否则其中一个将被覆盖。
If you need to load multiple config files normally they will be merged into one master config array. Name collisions can occur, however, if you have identically named array indexes in different config files. To avoid collisions you can set the second parameter to TRUE and each config file will be stored in an array index corresponding to the name of the config file. -
对不起hjpotter。我同意。谢谢
标签: php codeigniter