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 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?