简体   繁体   English

如何在Zend Framework 2中显示页面

[英]How to display page in zend framework 2

I want to display simple static page 我想显示简单的静态页面

my Controller 我的控制器

class WaitListController extends BaseController
{

    public function indexAction()
    {  
        $viewModel = new ViewModel();
        $Waitlistform = new \Webadmin\Form\WaitListForm();

       // return $viewModel->setVariables(array("customerform"=> $Waitlistform));
        return $viewModel->setVariables(array('userName','mujahed'));
        //return $viewModel;
    }

}

and my page is index.phtml in form folder but its not working giving following error 而且我的页面是form文件夹中的index.phtml,但无法正常工作,给出以下错误

/var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/Renderer/PhpRenderer.php:498

Message: 信息:

Zend\View\Renderer\PhpRenderer::render: Unable to render template "merchant/wait-list/index"; resolver could not resolve to a file

Stack trace: 堆栈跟踪:

#0 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/View.php(205): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\ViewModel))
#1 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/View.php(233): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#2 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/View.php(198): Zend\View\View->renderChildren(Object(Zend\View\Model\ViewModel))
#3 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php(102): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#4 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Zend\Mvc\MvcEvent))
#5 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#6 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('render', Object(Zend\Mvc\MvcEvent), Array)
#7 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(352): Zend\EventManager\EventManager->trigger('render', Object(Zend\Mvc\MvcEvent))
#8 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(327): Zend\Mvc\Application->completeRequest(Object(Zend\Mvc\MvcEvent))
#9 /var/www/html/restaurant/public/index.php(46): Zend\Mvc\Application->run()
#10 {main}

Unable to render template This error means, that you didnt created view script for action. 无法呈现模板此错误表示您未创建要执行操作的视图脚本。 Do you have index.phtml inside good filepath? 是否在良好的文件路径中包含index.phtml? Show us your file structure. 向我们展示您的文件结构。

Good file path for skeleton app: 骨架应用的好文件路径:

module/Application/view/application/index/index.phtml

so for you i think its should be: 所以对你来说,我认为应该是:

module/YOUR_MODULE_NAME/view/application/wait-list/index.phtml

Remember to use wait-list instead of WaitList. 记住要使用等待列表而不是WaitList。 ZF convert path from camel case. 采埃孚(ZF)从驼峰式保护套转换路径。

If you learning ZF2 use skeleton application, you will catch everything a lot faster 如果您学习使用ZF2的骨架应用程序,则可以更快地掌握所有内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM