Created
August 19, 2012 09:39
-
-
Save axooh/3393980 to your computer and use it in GitHub Desktop.
Drupal Preprocess Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Override or insert variables into the node templates. | |
| * | |
| * @param $variables | |
| * An array of variables to pass to the theme template. | |
| * @param $hook | |
| * The name of the template being rendered ("node" in this case.) | |
| */ | |
| function theme_preprocess_node(&$variables, $hook) { | |
| // Split Node view modes into separate template files (e.g. node--basic_element--teaser.tpl.php) | |
| $variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode']; | |
| // Optionally, run node-type-specific preprocess functions, like | |
| // theme_preprocess_node_page() or theme_preprocess_node_story(). | |
| $function = __FUNCTION__ . '_' . $variables['node']->type; | |
| if (function_exists($function)) { | |
| $function($variables, $hook); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment