检索视图 2 中被覆盖的主题挂钩的名称 (Drupal 6)

发布于 2024-08-12 17:22:01 字数 527 浏览 5 评论 0原文

我创建了一个视图(我们称之为my_view)。

在主题:信息部分中,如果我已记下建议的模板名称之一(views-view--my-view--default.tpl.php(或接近该名称)),并且使用该名称创建了我自己的模板文件。

这一切都工作正常,当我访问主题注册表时,我可以看到那里有一个带有模板名称的挂钩(views-view--my-view--default)。然而,这个钩子的类型字段是“engine”而不是“module”。我认为这是为了以视图制定自己主题的方式进行视图?

我想实现 hook_registry_alter 来修改此主题挂钩(以及以相同方式创建的其他挂钩),但我无法弄清楚如何检索这些挂钩的列表。

我尝试使用 array_keys(views_theme()) 来获取所有视图挂钩,但此列表不包含由覆盖模板文件创建的挂钩。它只包含像views_views_field等默认钩子

有没有办法以这种方式带回覆盖的视图主题钩子列表?

I have a created a view (lets call it my_view).

In the theme: information section if the view I have noted one of the suggested template names (views-view--my-view--default.tpl.php (or close to that)), and created my own template file with that name.

This all works fine and when I visit the theme registry, I can see there is a hook there with the name of the template (views-view--my-view--default). However this hook has a type field of 'engine' rather than 'module'. I assume this is to do view the way views works out its own theming?

I want to implement hook_registry_alter to modify this theme hook (and others created in the same way), but I cant work out how to retrieve a list of these hooks.

I tried using array_keys(views_theme()) to get all the views hooks back but this list doesn't contain hooks created by over-riding template files. It only contains the default hooks like views_views_field etc

Is there a way to bring back a list of views theme hooks over-ridden in this way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

皇甫轩 2024-08-19 17:22:01

我在这里回答,因为您最后的评论似乎表明您不再对追求最初的方法感兴趣,无论如何,600 个字符是不够的。

实现您想要的效果的另一种方法可能是使用子主题从其父主题的“继承”。换句话说,您可以将您的用户主题定义为管理主题的子主题。

通过这种方式,主题引擎将搜索模板 - 如果用户通过用户主题查看网站 - 首先在用户主题文件夹中搜索,然后在管理主题文件夹中搜索,然后在模块目录。

例如,这与 zen 使用的机制相同,让您可以使用入门工具包创建主题。

希望这有帮助!

I answer here as your last comment seems to indicate you are not interested anymore in pursuing your initial approach, and 600 chars would not be enough, anyhow.

An alternative approach to achieve what you want could be to use the "inheritance" of sub-themes from their parent theme. You could in other words define your user theme as a sub-theme of the admin theme.

In this way the theming engine would search for templates - in the case of a user viewing the site through the user theme - first in the user theme folder, then in the admin theme folder, and then in the module directory.

This is for example the same mechanism used by zen for letting you create your themes with the starter kit.

Hope this helps!

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