求教ZF中的setScriptPath

blessdyb 2009-12-26
开始学习zf,看看Beginning Zend Framework来入门。在其中碰到了下面的问题,请各位帮忙解答,谢谢。

我用的是zf 1.8.0的环境,用Zend_Tools生成了AccountController,其中有一个updateAction,在update.phtml
中我引用了includes/header.phtml这个公共文件。目录结构如下:
-controllers
      -AccountController
-views
     -scripts
          -accounts
                -update.phtml
          -includes
                -header.phtml

下面是AccountController与update.phtml的代码:
<?php

class AccountController extends Zend_Controller_Action
{
    //
    public function updateAction()
    {
        $view=new Zend_View();
    $view->addScriptPath(APPLICATION_PATH."/views/scripts/account");
    $view->render("update.phtml");
    }


}



<?=$this->doctype('XHTML1_STRICT')?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <?=$this->headTitle('blessdyb.com – Update Info')?>
    </head>
    <body>
    <?php $this->render('../includes/header.phtml')?>
    <h3>Update My Profile</h3>
    <form action="saveprofile" method="POST">
        <table width="500" border="0">
        <tr>
            <td>Username: </td>
            <td><input type="text" name="username" value="<?=$this->username?>"/></td>
        </tr>
        <tr>
            <td>Email: </td>
            <td><input type="text" name="email" value="<?=$this->email?>"/></td>
        </tr>
            <tr>
            <td>Password: </td>
            <td><input type="password" name="password" value="<?=$this->password?>"/></td>
        </tr>
        <tr>
            <td colspan="2">
            <input type="submit" value=" Update my account! " />
            </td>
        </tr>
        </table>
    </form>
    </body>
</html>

运行http://localhost/account/update后就会提示
Requested scripts may not include parent directory traversal ("../", "..\" notation)  

如果我不在update.phtml中调用header.phtml这个文件,那就没有问题,这里用到了setScriptsPath,是不是这块的设置有问题?
blessdyb 2009-12-26
自问自答了,原来是setScritpPath的问题
只要为header.phtml再加上一个setScriptPath就可以了
Global site tag (gtag.js) - Google Analytics