Coder Social home page Coder Social logo

Comments (5)

zfbot avatar zfbot commented on June 1, 2024

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF2-193

Known GitHub users mentioned in the original message or comment:
@YonmaN, @weierophinney

from zendframework.

jurajseffer avatar jurajseffer commented on June 1, 2024

This is indeed a problem for those who use SmartyModule for their rendering. I got around it by modifier SmartyRenderer's render() method:

foreach ($this->resolver()->getIterator() as $resolver) {
    if ($resolver instanceof TemplatePathStack) {
        $resolver->setDefaultSuffix(".tpl");
    }
}

from zendframework.

ebalicat avatar ebalicat commented on June 1, 2024

nice one, @jurajseffer ! I'm having the same problem myself in ZF2/Smarty Integration, that solves the problem. Thanks! But would it be possible to set the defaultsuffix on the module.config level? Im using the ZF2/Smarty Integration Module made by https://github.com/Domi-cc/SmartyModule and Im seeing this codebut the defaultSuffix variable is not working

'view_manager' => array(
        display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'defaultSuffix'            => '.tpl',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'layout/layout'           => __DIR__ . '/../../Application/view/layout/layout.tpl',
            'error/404'               => __DIR__ . '/../../Application/view/error/404.phtml',
            'error/index'             => __DIR__ . '/../../Application/view/error/index.tpl',
        'application/index/index' => __DIR__ . '/../../Application/view/application/index/index.tpl',
        ),

from zendframework.

jurajseffer avatar jurajseffer commented on June 1, 2024

@ebalicat I use the same module. I only just started using ZF2 and haven't figured out a way how to access the config in SmartyRenderer yet.
jurajseffer/SmartyModule@d9e0bb2

from zendframework.

iquabius avatar iquabius commented on June 1, 2024

This was fixed with #3996.

A new option was added:

'view_manager' => array(
        display_not_found_reason' => true,
        'display_exceptions'          => true,
        'doctype'                          => 'HTML5',
        'default_template_suffix'     => 'tpl', // you can use '.tpl' here, it does not matter
        'not_found_template'          => 'error/404',
        'exception_template'          => 'error/index',
        'template_map' => array(
            'layout/layout'           => __DIR__ . '/../../Application/view/layout/layout.tpl',
            'error/404'                 => __DIR__ . '/../../Application/view/error/404.phtml',
            'error/index'               => __DIR__ . '/../../Application/view/error/index.tpl',
        'application/index/index' => __DIR__ . '/../../Application/view/application/index/index.tpl',
        ),

And if you want to refer to a template that has a different extention than the default ('tpl' in this case), you can add the extention in the template name:

    public function fooAction()
    {
        $model = new Zend\View\Model\ViewModel($data);
        $model->setTemplate('my-module/my-controller/foo.html'); // if you omit the extention, it will rely on the default (tpl) 
       return $model;
     }

from zendframework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.