Home > Backend Development > PHP Tutorial > zend framework 中zend_view的疑惑,该怎么解决

zend framework 中zend_view的疑惑,该怎么解决

WBOY
Release: 2016-06-13 13:49:35
Original
841 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template