【问题标题】:Yii Widget component cannot find it's view in serverYii Widget 组件在服务器中找不到它的视图
【发布时间】:2015-10-07 19:21:34
【问题描述】:

我是 YII 的新手,我使用 Eclipse IDE 和 XAMPP 开发了一个 yii 应用程序。它在我的本地机器上的 Windows 平台上完美运行。但是当我将它部署到服务器时,它无法正常工作。

这是我的小部件控制器 "/protected/components/NotificationWidget.php"

<?php


class NotificationWidget extends CWidget {public function run() {
    $notifications = Notification::model()->findAllByAttributes(array('Date'=>date('Y-m-d')));;

    $this->render('/protected/components/Views/notification.php', array(
        'notifications'=>$notifications   
    ));
}}?>

这是我的观点

"/protected/components/视图"

<li class="dropdown notifications-menu">
<!-- Menu toggle button --> <a href="#" class="dropdown-toggle"
data-toggle="dropdown"> <i class="fa fa-bell-o"></i> <span
    class="label label-warning"><?php echo sizeof($notifications);?></span> </a>
<ul class="dropdown-menu">
    <li class="header">You have <?php echo sizeof($notifications);?>
        notifications</li>
    <li>
        <!-- Inner Menu: contains the notifications -->
        <ul class="menu">
        <?php
        foreach($notifications as $notification) {
            echo "<li>".
    "<a href='#'>".
    " <i class='fa fa-users text-aqua'></i>". $notification->Description.
    "</a></li>";
        }
        ?>
        </ul></li>
    <li class="footer"><a href="#">View all</a>
    </li>
</ul></li>

它给出以下错误。

NotificationWidget 找不到视图“/protected/components/Views/notification.php”。

任何人都可以帮助解决这个问题。

【问题讨论】:

    标签: php yii


    【解决方案1】:

    如果服务器是 unix,则检查路径中小写/大写形式的完美匹配

    NotificationWidget cannot find the view "/protected/components/Views/notification.php".
    

    我认为应该由

    NotificationWidget cannot find the view "/protected/components/views/notification.php".
    

    【讨论】:

    • 没有相同的结果。找不到视图。实际上,这是在我的本地机器上工作的代码,而在服务器上却没有。 findAllByAttributes(array('Date'=>date('Y-m-d')));; $this->render(''notification', array('notifications'=>$notifications )); } } ?>
    • 请更新问题并正确格式化此代码。谢谢
    • &lt;?php class NotificationWidget extends CWidget { public function run() { $notifications = Notification::model()-&gt;findAllByAttributes(array('Date'=&gt;date('Y-m-d')));; $this-&gt;render(''notification', array( 'notifications'=&gt;$notifications )); } } ?&gt; 我的视图名称是notification.php 在/protected/components/views
    猜你喜欢
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多