I'm having difficulty fully grasping the semantics in implementing hook themes, and consequently understanding the way in which preprocess/process functions are created. I'm using "The Definitive Guide to Drupal 7", which states(technically) that the following code should implement/define/ and output a theme function.
/**
* Implements hook_theme().
**/
<?php
// core/module_urtheme() - kiwi is the themesname
function node_kiwi(){
return array(
'addBlock' => array(
'block' => 'content'
),
);
}
//define theme_functionName/ should it be theme_addBlocK?
function kiwi_addBlock($block){
return '<div class="kiwi-block">'.$block.'</div>';}
//use
print theme('addBlock',$block)
My problem lies in my utter confusion in regards to the syntax preprocess functions have:
<?php
/**
* Implements template_preprocess_THEMEHOOK().
*/
function HOOK_preprocess_THEMEHOOK(&$variables) {
// Changes go here.
}
Ultimately I'm aware both HOOK
and THEMEHOOK
are placeholders, but what should replace them, for HOOK
the module/template/theme? For THEMEHOOK
- the function's name/the theme/? I tried comparing the the theme hook implementation above, but it just made me more confused.
I apologize in advance for any naive mistakes I might have made/said. Any and all help will be much appreciated :) .
As far as I know, HOOK is the name of the module or theme, and THEMEHOOK is the hook defined inside hook_theme(), the typical ones are "block", "node"... etc. For example: Yourmodule_preprocess_node(&$variables).