我正在通過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