dousi2029 2014-01-07 09:18
浏览 58
已采纳

在zend框架2中为视图文件设置视图后缀

The default zend framework 2 configuration relies on phtml files for view rendering. However, for security reasons I want to change that to php.

From this link I understand that I need to create a custom view helper in order to do that or is there a setting I can change to change the suffix from phtml to php and how is this done exactly?

Update: I got it working, but not the way I want. If possible I would like to get the answer from guessimtoolate working. So I prefer something like this in my module.config.php:

'view_manager' => array(
    'default_suffix' => 'php',
    //etc...
)
  • 写回答

3条回答 默认 最新

  • duanqi5333 2014-01-07 10:14
    关注

    If my memory serves my well, you can define that in default_suffix key in your module's configuration file under view_manager, e.g.:

    return array(
        // ...
        'view_manager' => array(
            'default_template_suffix' => 'php',
            // ...
        ),
        // ...
    );
    

    This should make template file resolvers to look for .php files instead of .phtml.

    Not entirely sure how's that an improvement, but it can be done.

    UPDATE: Sorry, I've wrote the wrong configuration key name -- it should be default_template_suffix and not default_suffix. It is used, e.g.: in Zend\Mvc\Service\ViewTemplatePathStackFactory where path stack resolvers are born :).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化