【发布时间】:2013-12-15 22:12:22
【问题描述】:
我在使用 codeIgniter 时遇到了问题,我找不到答案。 我想要做的是用一个管理多个站点的管理系统来构建一个 CMS。 我有标准的类和函数,但有时一个站点比另一个站点运行得更好,所以我需要专门为那个站点更改一个控制器。
我现在的问题是我不知道如何更改自动加载控制器/模型并查看它必须首先在其自己的文件夹中查找的位置(如果存在)。如果存在从自己的文件夹加载文件,则使用全局文件。
在其他方面我需要这个。
控制器新闻(http://mywebsite.com/news/ 在目录中。 自己的文件夹是 /home/user/domains/website/public_html/codeIgniter/controllers 全局文件夹是 /home/libs/codeIgniter/controllers
全局文件夹在网站的 index.php 设置中设置。
首先它需要检查文件的第一个文件。如果不存在使用全局文件。 我希望你能帮助我。
我添加了一个几乎相同的代码,但随后使用视图控制器,然后它是另一个功能。我也想做这个的标准功能,所以我不需要使用标准功能以外的其他功能。
谢谢。
<?php
/* !DESCRIPTION: This method behaves the same as the default $this->load->view() except it allows you to
include files outside your root application view folder. It will change the path, include the file,
then change the path back to the original. Nice to have when using shared templates over multiple sites.
*/
//!VAR -> $path :: The absolute path to the view folder (IE: /var/shared/codeigniter/views/)
//!VAR -> $view :: The view file name (IE: shared-header)
//!VAR -> $data :: The variables and values you wish to pass to the view, if any (Defaults to empty array())
//!VAR -> $return :: Set to TRUE if you want to return the value rather than add to the view (Defaults to FALSE)
function external_view($path, $view, $data=array(), $return=FALSE)
{
$__ci =& get_instance();
$op = $__ci->load->_ci_view_path;
$__ci->load->_ci_view_path = $path;
$v = $__ci->load->view($view, $data, $return);
$__ci->load->_ci_view_path = $op;
if ($return === TRUE) { return $v; }
}
?>
【问题讨论】:
-
您可能需要hmvc 用于 CI。有一段时间没有使用 CI,但允许 MVC 设计模式,从不同的控制器调用控制器/视图和附加组件,所有这些都是 imo
标签: php codeigniter frameworks