Created
September 26, 2013 16:25
-
-
Save makbeta/6716587 to your computer and use it in GitHub Desktop.
Drupal7: Make node fields variables for global access
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 | |
//this goes into template.php function | |
function theme_preprocess_page(&$variables, $hook) { | |
if(isset($variables['node'])) { | |
$node = node_load($variables['node']->nid); | |
if($node->type == 'homepage') { | |
$field_name1 = 'field_left'; | |
$field_name2 = 'field_middle'; | |
$field_name3 = 'field_right'; | |
$variables[$field_name1] = field_view_field('node', $node, $field_name1, 'default'); | |
$variables[$field_name2] = field_view_field('node', $node, $field_name2, 'default'); | |
$variables[$field_name3] = field_view_field('node', $node, $field_name3, 'default'); | |
} | |
} | |
} | |
?> | |
// this goes into page.tpl.php | |
<?php print render($field_left); ?> | |
<?php print render($field_middle); ?> | |
<?php print render($field_right); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment