0

Codeigniter をローカルで使用してカスタム CMS を開発してきましたが、ステージング サーバーにアップロードしてさらにテストを行う必要があるところまで来ました。

ウィジェット システムを使用するサイトのサイドバー セクションを除いて、すべてが機能します。ローカルで 5.4.4 を実行していて、サーバーが 5.3 だったので、最初は PHP のバージョンの違いだけだと思っていました。サーバーを 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

必要なだけで終わったsubdir = strtolower($subdir);

みんな助けてくれてありがとう

于 2012-09-21T22:03:51.283 に答える
0

ステージング サーバーの場合は、php.ini ファイルに移動して設定します。

error_reporting = E_ALL | E_STRICT
display_errors = On

これにより、検出されたエラーが出力されるため、デバッグできます。

于 2012-09-21T19:50:24.450 に答える