Last active
December 22, 2015 01:18
-
-
Save jeremycaldwell/6394982 to your computer and use it in GitHub Desktop.
Drupal 7 - Node preprocess
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
/** | |
* Override or insert variables into the node templates. | |
* | |
* @param $vars | |
* An array of variables to pass to the theme template. | |
*/ | |
function THEMENAME_preprocess_node(&$vars) { | |
$node = $vars['node']; | |
// Custom submitted text | |
switch ($vars['view_mode']) { | |
case 'full': | |
$vars['submitted'] = t('By') . ' ' . t('!username', array('!username' => $vars['name'])) . ' ' . t('on') . ' ' . '<time datetime=22-01-2011 pubdate>' . format_date($vars['node']->created, 'custom', 'F j, Y') . '</time>'; | |
break; | |
case 'teaser': | |
$vars['submitted'] = '<time datetime=22-01-2011 pubdate>' . format_date($vars['node']->created, 'custom', 'F j, Y') . '</time>'; | |
break; | |
} | |
switch ($node->type) { | |
case 'article': | |
switch ($vars['view_mode']) { | |
//case 'teaser': | |
case 'teaser_featured': | |
// Add read more to body suffix | |
$vars['content']['body']['#suffix'] = l(t('Read more') . ' »', 'node/' . $node->nid, array('html' => TRUE, 'attributes' => array('class' => 'readmore'))); | |
$vars['content']['field_featured_image']['#weight'] = '10'; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment