matt.k Posted February 15, 2017 Share Posted February 15, 2017 Hi! I am trying to create a custom page in front office via custom module. Here is a minimal example: mk_formpage/ ├── mk_formpage.php ├── controllers/ │ └── front │ └── display.php └── views/ └── templates └── front └── display.tpl > display.php: <?php class mk_formpagedisplayModuleFrontController extends ModuleFrontController{ public function initContent(){ parent::initContent(); $this->setTemplate('module:mk_formpage/views/templates/front/display.tpl'); } } I can generate page using simple template: > display.tpl: <!doctype html> <!-- Note: this is just a fragment, it will not work --> <head> {block name='head} {include file='_partials/head.tpl'} {/block} </head> <body> Here my content {block name='javascript_bottom'} {hook h='...ClosingTag'} </body> </html> What I can't get to work is using more general templates: > display.tpl variation: {extends file='page.tpl'} {block name="page_content"} Here my content {/block} The error I am getting is: ContextErrorException in smarty_internal_templatebase.php(157) : eval()'d code line 445: Warning: htmlspecialchars() expects parameter 1 to be string, array given I have tried to debug this but without any luck. Docs are actually harmful since those are outdated Any help is appreciated! Link to comment Share on other sites More sharing options...
matt.k Posted February 16, 2017 Author Share Posted February 16, 2017 (edited) Finally solved the problem by adding smarty variable 'message'. I wonder if this is a bug? <?php class mk_formpagedisplayModuleFrontController extends ModuleFrontController{ public function initContent(){ parent::initContent(); $this->context->smarty->assign('message', 'Why no one mentions this!??!'); $this->setTemplate('module:mk_formpage/views/templates/front/display.tpl'); } } Edit: Alternative solution is to add following block to the template: {block name="notifications"}{/block} Edited February 18, 2017 by matt.k (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now