0

我一直在本地使用 Codeigniter 开发自定义 CMS,我刚刚到了需要将其上传到登台服务器以进行更多测试的地步。

除了使用小部件系统的站点的侧边栏部分外,一切正常。我最初认为这只是 PHP 版本之间的差异,因为我在本地运行 5.4.4 而服务器是 5.3。将服务器升级到 5.4.7 后,侧边栏仍然没有出现。我没有收到任何错误,只是没有显示。

这是小部件库代码:

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Widgets {

    private $_ci;
    protected $parser_enable = FALSE;

    public function __construct() {
        $this->widgets();
    }

    public function widgets(){
        $this->_ci =& get_instance();
    }

    public function build($view,$data=array()){
        $view = get_class($this).'/'.$view;
        $subdir = '';
        if (strpos($view, '/') !== FALSE)
        {
                // explode the path so we can separate the filename from the path
                $x = explode('/', $view);

                // Reset the $class variable now that we know the actual filename
                $view = end($x);

                // Kill the filename from the array
                unset($x[count($x)-1]);

                // Glue the path back together, sans filename
                $subdir = implode($x, '/').'/';
        }

        $widget_view = APPPATH.'widgets/'.$subdir.'views/'.$view.EXT;

        if(file_exists($widget_view)){
            $widget_view = '../widgets/'.$subdir.'views/'.$view.EXT;
            if($this->parser_enable){
                $this->_ci->load->library('parser');
               return $this->_ci->parser->parse($widget_view,$data,TRUE);
            }
            else{
                return $this->_ci->load->view($widget_view,$data,TRUE);
            }
        }

        return FALSE;
    }

    public function __get($var) {
        static $ci;
        isset($ci) OR $ci = get_instance();
        return $ci->$var;
    }
}

有什么东西跳出来可能导致它不显示吗?

有什么我应该考虑使其兼容的,例如服务器模块吗?服务器上的什么可能会影响这一点?

编辑:

我的小部件位于以下路径中:

/public_html/application/widgets/recent_news/views/view.php

$widget_view = 'widgets/'.$subdir.'views/'.$view.EXT;变量正在返回,widgets/Recent_news/views/view.php它被传递给:

if(file_exists($widget_view)){
    return $this->_ci->load->view($widget_view,$data,TRUE);
}

$widget_view 中的应用程序路径在登台服务器上似乎不正确,因此 file_exists() 返回 false 并且不加载视图(无论如何都会有不正确的路径)。

我似乎无法让它读取正确的路径,有什么建议吗?

4

2 回答 2

0

如果是登台服务器,进入 php.ini 文件并设置

error_reporting = E_ALL | E_STRICT
display_errors = On

这将输出它发现的任何错误,以便您对其进行调试。

于 2012-09-21T19:50:24.450 回答
0

最终只需要subdir = strtolower($subdir);

感谢大家的帮助

于 2012-09-21T22:03:51.283 回答