maxnuf / MaxnufSmarty

Zend Framework 2 Module that provides a Smarty rendering strategy
3 stars 3 forks source link

Hey. #4

Closed xro closed 11 years ago

xro commented 11 years ago

First of all thanks for creating this stuff. As integrating smarty into ZF2 for framework newbies is nightmare.

Second, have installed your module but in templates I get displayed {$this->doctype()} instead of having doctype executed and outputted. Any possible reasons? thanks

maxnuf commented 11 years ago

It seems Smarty isn't loaded at all. Make sure that you added 'MaxnufSmarty' to 'modules' in the config/application.config.php file.

xro commented 11 years ago

Thanks for reply. Managed to have operational maxnufsmarty now (fixed my config entries). ..but the other issue came out.

say this works perfectly: {$this->doctype()} but having something like: {$this->headScript()->prependFile($this->basePath() . '/js/html5.js', 'text/javascript', array('conditional' => 'lt IE 9',)) ->prependFile($this->basePath() . '/js/bootstrap.min.js') ->prependFile($this->basePath() . '/js/jquery.min.js')} will throw SmartyCompilerException with Syntax Error message. Its due to concatenation struff (me thinks). So wanted just to do {php} echo $this->headScript()->prependFile($this->basePath() . '/js/html5.js', 'text/javascript', array('conditional' => 'lt IE 9',)) ->prependFile($this->basePath() . '/js/bootstrap.min.js') ->prependFile($this->basePath() . '/js/jquery.min.js'); {/php}

but seems php tag is faulty with your implementation getting error 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for php

Tried to resolve it myself but no fun. This issue is probably more interesting for you:)

maxnuf commented 11 years ago

well can't and shouldn't use {php} tags, they are deprecated. See http://www.smarty.net/docs/en/language.function.php.tpl

I'm not sure why concatenation doesn't work. I'll look into it. In the meantime you could maybe work around this issue by assigning it to a variable first using {assign}?

Spiderschwein commented 11 years ago

Yeah concatenation with the .-operator like php won't work, because the . is special in smarty for array access.

I'd the same problem but i solved it with the cat modifier from smarty.

so instead of prependFile($this->basePath() . '/js/jquery.min.js')} simply write prependFile($this->basePath()|cat:'/js/jquery.min.js')}

maxnuf commented 11 years ago

the cat modifier will work. note that you'll also get trouble using

array('foo' => 'bar')

simply use '[ ]' instead

['foo' => 'bar']