视图在页面中呈现两次?

时间:2012-07-02 12:03:34

标签: php zend-framework

我正在zend框架中开发一个网站。我在页面的head部分包含了js文件(jquery.js)(zend layout)。如果网址是这样的话,我的所有页面都正常工作

http://mywebsite.com/controller_name/action_name

我的问题是,如果我将变量添加到页面网址,就像这样

http://mywebsite.com/controller_name/action_name/variable_1/variable_2

然后视图呈现两次并重复输出(页面html)。我该如何解决这个问题?

这是layout.phtml的代码

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>title</title>
        <script type="text/javascript" src="/js/jquery.min.js"></script>
        <script src="/js/mainscript.js"></script>
        <link rel="stylesheet" type="text/css" href="/css/hello.css" />
    </head>
    <body>
        <?php echo $this->layout()->content ?>
    </body>
</html>

下面是我的控制器的代码。

class CoursesController extends MyZend_Controller_Action
{

    public function init()
    {   
        $this->_helper->layout->setLayout('courseslayout');
        $this->view->actionName = $this->_request->getActionName();
    }

    public function indexAction()
    {
        $this->view->Courses_Progress = "10%";  
    } // end function indexAction()

    public function chineseAction()
    {
        $this->view->Courses_Progress = "10%";
    } // end function chineseAction()

    public function dutchAction()
    {
        $this->view->Courses_Progress = "20%";

    } // end function dutchAction()

    public function englishAction()
    {
        $this->view->Courses_Progress = "30%";
    } // end function englishAction()

} // end CoursesController

0 个答案:

没有答案
相关问题