2

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?

mac
  • 42,153
  • 26
  • 121
  • 131
grahamu
  • 53
  • 2
  • 5
  • 1
    What is your end goal? I'm not sure you are going about this the right way. – googletorp Nov 26 '09 at 09:04
  • The end goal was to be able to tell the theming system to to look for views templates first in the sites default theme, followed by the admin theme. I would accomplish this by modifying the 'theme paths' attribute of the theme hook. This was to over-ride the default behavior of only searching for templates in the theme that the view was being displayed in. However after spending a while on this I realized the approach was flawed as the views theme hooks don't make use of the normal template suggestions approach. – grahamu Nov 26 '09 at 20:44

1 Answers1

1

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!

mac
  • 42,153
  • 26
  • 121
  • 131
  • Thanks for that suggestion. Unfortunately my use case is a little unusual as the view is displayed in the admin theme, yet I still want the theme system to look first for view templates in the default theme, then the admin theme. – grahamu Nov 27 '09 at 11:08
  • @granhamu - How different are the two themes? Is merging them into a single one and inserting some role-based logic in the theme function an option? While I am sure there are ways to achieve what you want (if not with Drupal at least by using PHP directly) drupal is designed to keep themes apart and what you want/need to do seems to go in the opposite direction (if I got you right: you want to force a theme to use pieces of another, unrelated one). – mac Nov 27 '09 at 11:45
  • @granhamu - In the above comment I assumed that you **always** have a "backup template" in the admin theme, but you want to use it only if the user theme does not have any alternative one. If that is not the case (i.e.: the admin theme only have templates when the user theme does not) then the solution is obvious: **just take my original answer and swap the hierarchy logic: make the admin theme a sub-theme of the user one**. – mac Nov 27 '09 at 11:51