可以在多个应用程序中使用的模板的最佳位置是什么? [英] What is the best place for a template that can be used in multiple apps?

查看:19
本文介绍了可以在多个应用程序中使用的模板的最佳位置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Symfony 框架中有 2 个应用程序:后端和前端.

I have 2 apps in my Symfony framework: backend and frontend.

是否可以有两个应用都使用的模板?

is it possible to have templates that are being used by both apps?

如果是这样,放置这些模板的最佳位置是什么?

And if so, what is the best place to put those template?

推荐答案

过去我能够克服这个问题的唯一方法是为共享部分创建一个插件.

The only way I've been able to overcome this in the past has been to create a plugin for the shared pieces.

IE:在名为

模板插件

在其中创建一个模块文件夹,然后在其中创建一个常规的模块文件夹结构.

Within that, create a modules folder, and within that, create a regular module folder structure.

模板路径示例:

sf_root/plugins/TemplatesPlugin/modules/book/pageSuccess.php
sf_root/plugins/TemplatesPlugin/modules/book/_title.php

确保在 config/ProjectConfiguration.class.php 中启用了插件(如果您使用的是 enableAllPluginsExcept,否则您需要将其添加到应该已经存在的 plugins 数组中).

Ensure the plugin is enabled in config/ProjectConfiguration.class.php (if you are using enableAllPluginsExcept it will be, otherwise you need to add it into the plugins array that should already be there).

然后您可以像访问任何其他模板一样访问这些模板,例如:

You can then access these templates as any other templates, for example:

include_partial('book/title', array('title'=>'hello'));

虽然这感觉有点黑客,但效果很好.

Whilst this feels a bit of a hack, it works pretty well.

这篇关于可以在多个应用程序中使用的模板的最佳位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆