我正在通过Apress的书“Beginning Zend Framework”的工作方式 - 我正努力获得其中一个示例。zend set/getScriptPath问题:
目标是使用setScriptPath来规避标准目录结构。本教程不是将操作的相关视图脚本存储在脚本目录中,而是要求您将其保存在项目目录中的其他位置。我将它存储在应用程序的根目录中。这里的代码:
public function updateAction()
{
//get the artists
$artist = array("Thievery Corporation","The Eagles","Elton John");
//set view variables
$this->view->artists = $artist;
//locate the view
$this->view->setScriptPath('/application/');
$this->render("update");
}
但是,当我尝试去www.domain.com/account/update - 它说它找不到脚本。我需要知道的是如何定义相对于框架结构的文件夹的位置。我在现有脚本文件夹内的脚本上使用了getScriptPath,但它们返回绝对硬盘路径,我不确定是否正确 - 当然,我无法使用update.phtml脚本中的getScriptPath,因为我可以不加载它。
任何能帮助我的zend大师?
doh,我的错误 - 好吧,不是真的。我需要实例化Zend_View对象 - 本教程未在动作代码中显示。我的坏 - 谢谢你的帮助! – sunwukung 2009-10-21 10:50:49
如果您只是想添加到堆栈而不是替换当前路径,您还可以使用$ this-> view-> addScriptPath(...)。 – voidstate 2011-06-06 11:27:45