zend framework 中zend_view的疑惑,該怎麼解決
來源:互聯網
上載者:User
zend framework 中zend_view的疑惑
我在使用zend_view時感覺到很奇怪的事情是在使用script檔案時,
class PutpostController extends Zend_Controller_Action
{
function indexAction()
{
//Zend_Loader::loadClass('Zend_View');
$view=new Zend_view();
$view->setScriptPath('./application/views/scripts/posts');//////視圖指令碼所在的目錄
foreach($view->getScriptPaths () as $onepath)
{
echo $onepath.'
';
}
$view->render("postnews.phtml");
}
}
我設定了這個指令碼目錄後,制定phtml檔案,那應該是用這個模板來完成輸出吧,可是我執行http://localhost:8082/putpost/時,卻提示我找不到script
Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'putpost/index.phtml' not found in path (.\application\views\scripts\)'
看上去就是還是使用了他預設的路徑了。然後我故意setScriptPath到一個不存在的目錄的話,卻又是提醒我我那個路徑不存在,那也就是說還是要執行路徑設定的了?既然這樣為什麼我指定自己的檔案就不行呢,一定要按照預設的putpost/index.phtml來尋找(我在這個目錄下放置檔案後是有用的,但是是以index.phtml來輸出而不是以我指定的postnews.phtml。
還有就是難道在action中一定要制定view嗎,我直接用echo,而不制定模板的話感覺也沒有任何作用,還是一直在提醒我putpost/index.phtml不存在?
zend_view和script是這樣用的嗎?
------解決方案--------------------
能不能不加那個 . ./application/views/scripts/posts
------解決方案--------------------
頂
------解決方案--------------------
能不能不加那個 ../application/views/scripts/posts