主题文件夹之外的 Drupal 主题文件
除了主题文件夹之外,是否有地方可以放置覆盖主题文件?例如,如果我想为多个主题以相同样式覆盖视图行的外观,而不必使用多个文件。
如果没有通用的方法来执行此操作(对于任何主题文件),是否有一种方法可以对视图的主题文件执行此操作?
Is there a place where I can place override theme files other than a theme's folder? For example, if I wanted to override the appearance of a view's row in the same style for more than one theme without having to use more than one file.
If there isn't a generic way to do this (for any theme file), is there a way to do it for a view's theme files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在模块中,您可以使用 hook_theme 为视图行声明主题函数或模板。这样,您的单个模板将被所有主题使用,而无需其中任何特殊代码。请参阅 Views 的 API 高级帮助页面。
In your module, you can use hook_theme to declare a theme function or template for your view's row. This way, your single template will be used by all your themes without any special code in them. See the Theming your views in your module section in the Views's API Advanced Help page.
您可以在 tpl.php 文件中包含
include_once
类型语句,然后从任意位置导入代码。这样你就可以有任意数量的文件引用一个文件。但不建议这样做,因为如果您移动主题文件夹或重命名任何内容,这可能会更困难。此外,如果您将主题放在另一个站点中,您需要跟踪所有这些偏离主题的黑客行为。
You could include an
include_once
type statement in your tpl.php file and just import the code from where ever. This way you have any number of files that refer to one.It is not recommended though since if you move your theme folder or rename anything this can be harder. Also if you put your theme in another site you need to keep track of all of these off-theme hacks.
我认为视图在主题文件夹内寻找 tpls。不过,拥有这样的东西真是太好了。
I think views seeks tpls inside of the theme folder. It's be nice to have something like that though.