主题文件夹之外的 Drupal 主题文件

发布于 2024-10-05 19:55:58 字数 127 浏览 0 评论 0原文

除了主题文件夹之外,是否有地方可以放置覆盖主题文件?例如,如果我想为多个主题以相同样式覆盖视图行的外观,而不必使用多个文件。

如果没有通用的方法来执行此操作(对于任何主题文件),是否有一种方法可以对视图的主题文件执行此操作?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

何其悲哀 2024-10-12 19:55:58

在模块中,您可以使用 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.

疾风者 2024-10-12 19:55:58

您可以在 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.

伴我老 2024-10-12 19:55:58

我认为视图在主题文件夹内寻找 tpls。不过,拥有这样的东西真是太好了。

I think views seeks tpls inside of the theme folder. It's be nice to have something like that though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文