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
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.