0

プロジェクトで Yii ウィジェットを作成していますが、すべての命名規則に正しく従っているにもかかわらず、問題が発生しました。

エラーが発生しました

include(RecentCommentsWidget.php): failed to open stream: No such file or directory

main.phpのパスapplication.components.*を正しく含めましたが、検出されない理由がわかりません。

recentCommentsWidget.phpは、コンポーネントディレクトリ内のビューディレクトリに保存されます

不足しているものはありますか?

編集:これがRecentCommentsWidgetクラスです(パス=>アプリケーション/コンポーネント)

class RecentCommentsWidget extends CWidget
{
private $_comments;
public $displayLimit = 5;
public $projectId = null;

public function init()
{
    if(null !== $this->projectId)
        $this->_comments = Comment::model()->with(array(
            'issue'=>array('condition'=>'project_id='.$this->projectId)))->recent($this->displayLimit)->findAll();
    else
        $this->_comments = Comment::model()->recent($this->displayLimit)->findAll();
}

public function getData()
{
    return $this->_comments;
}

public function run()
{
    // this method is called by CController::endWidget()
    $this->render('recentCommentsWidget');
}
}

recentCommentsWidget ファイル (パス => application/components/views)

<ul>
    <?php foreach($this->getData() as $comment): ?>
    <div class="author">
        <?php echo $comment->author->username; ?> added a comment.
    </div>
    <div class="issue">
        <?php echo CHtml::link(CHtml::encode($comment->issue->name),array('issue/view', 'id'=>$comment->issue->id)); ?>
    </div>
    <?php endforeach; ?>
</ul>

これが私がそれをビューと呼んでいる方法です

<?php $this->widget('RecentCommentsWidget'); ?>

解決済み: recentCommentsWidget.phpの代わりにrecentComments.phpを書いていました

4

0 に答える 0