Community

Is theme hooks the same as theme functions and what triggers what?

I pretty much understand API hooks that is not what I am interested in.

My problem is that I cannot see the big picture of theme hooks and how they work.

I cannot see they are event driven like API hooks.

Is 'theme functions' the same as 'theme hooks' or are theme functions just named in accordance with the hook name?

I have the idea that the theme() function calls the different theme functions and if preprocess and process functions exists the are invoked berfore. This way you can manipulate data kind of an override.

I am sure I am not the first asking help in this subject - but couldn't find any thing...

Hope you guys can help - thx ; )

Comments

Honestly, this is a huge

Honestly, this is a huge subject and almost no one understands it all except maybe sun and chx. Sadly I am not joking.

hook_theme() used to register templates and theme functions, you can use either. Preprocess and process functions you get for free, correct, variables passed in by reference, modify or create variables before they get to the theme function or template.

"Is 'theme functions' the same as 'theme hooks' or are theme functions just named in accordance with the hook name?"

Certainly what is referred to as theme function in Drupal are functions that you can rename and thus override the default function, for example theme_item_list() can be mythemeormodule_item_list(). So in practice a theme function is much like a template - you can create new name spaced variants and they override.

Also the aforemention preprocess and process functions are often lumped into this group of "theme functions", hower they do no override.

Of course it does not end there, this is just beginning, you have other hooks as well, like hook_page_alter, hook_page_build and it goes on and on. Not to mention that almost all output in Drupal will come via an enormous stack of functions, all sticking their oar in along the way...

FYI if you did not find anything then you are not looking in the right places - this subject is broad and deeply discussed in many places, also the book Drupal 7 Module Development has a very good section on the Drupal theme layer.

Yup very huge

Thank you - for your reply.

And I agree every time I think I got it new stuff appears - but API hook I understand ( I think )
I actually have the book and It really gives me a lot - good book totally agree.

How do you think about theme hooks? I find all sorts of stuff the problem is that noting is covering it fully : )

Best Thomas

Abroad is nice but 127.0.0.1 is best :)

API hooks and theme hooks

Are hooks always events you can hook into and are theme hooks also API hooks that simply shouldn't be used by themes. And theme hooks is the same as API hooks but isn't for modules. In other words I am a bit confused about:

========================================
We have API hooks and theme hooks. A theme hook is simply the name of a particular way to markup some data. E.g. parsing data to item_list theme hook will result in a different markup then passing data to the links theme hook.
However while normally every module's hook function will be called when Drupal invokes an API hook***only one theme hook implementation will be invoked when Drupal invokes a theme hook.
========================================
From the book Drupal 7 Module Development

I as see it now is that hooks are the same and then we have to categories: API hooks and them hooks.

Hope you guide me a little

Best Thomas

Abroad is nice but 127.0.0.1 is best :)

nobody click here