Zend_view in zendframework-php Tutorial

Source: Internet
Author: User
Zend_view doubts in zendframework I felt strange when using zend_view: when using a script file, classPutpostControllerextendsZend_Controller_Action {& nbsp; functionindexAction () & nbsp ;{& nbsp; zend_view in Zend_Lo zend framework
The strange thing I felt when using zend_view is that when using a script file,
Class PutpostController extends Zend_Controller_Action
{
Function indexAction ()
{
// Zend_Loader: loadClass ('zend _ view ');
$ View = new Zend_view ();
$ View-> setScriptPath ('./application/views/scripts/posts'); // Directory of the view script
Foreach ($ view-> getScriptPaths () as $ onepath)
{
Echo $ onepath .'
';
}
$ View-> render ("postnews. phtml ");
}
}
After I set this script directory and set the phtml file, we should use this template to complete the output. However, when I run http: // localhost: 8082/putpost, it prompts that I cannot find the script.
Fatal error: Uncaught exception 'zend _ View_Exception 'with message 'script' putpost/index. phtml' not found in path (. \ application \ views \ scripts \)'
It seems that the default path is still used. Then I intentionally setScriptPath to a non-existent directory, but reminded me that my path does not exist. that is to say, I still need to set the path? In this case, why can't I specify my own file? it must follow the default putpost/index. phtml to search (it is useful after I put files in this directory, but it is based on index. phtml is used to output messages instead of postnews. phtml.
Is there another way to define a view in action? if I use echo directly without creating a template, it does not work. I still keep reminding me that putpost/index. phtml does not exist?
Is zend_view and script used in this way?

------ Solution --------------------
Can you not add the ../application/views/scripts/posts?
------ Solution --------------------
Top
------ Solution --------------------
Can you not add the ../application/views/scripts/posts?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.