Created
September 18, 2013 08:27
-
-
Save fieke/6606235 to your computer and use it in GitHub Desktop.
Add link to news data
This file contains 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
/* | |
* Implements hook_preprocess_node | |
*/ | |
function theme_preprocess_node(&$variables, $hook) { | |
switch ($variables['type']) { | |
case 'news': | |
// ADD LINK TO NEWS DATA - HOMEPAGE | |
if($variables['teaser'] == true && isset($variables['content']['title']['#items']['0']['value'])) { | |
// GET NODE TITLE, DATE AND NODE URL | |
$orgdate = $variables['content']['post_date']['#items']['0']['value']; | |
$orgtitle = strip_tags($variables['content']['title']['#items']['0']['value']); | |
$linktonode = $variables['node_url']; | |
// NEW TITLE + DATE VARIABLE | |
$newtitle = '<div class="teasertitle">' . $orgtitle . '</div> <div class="teaserdate">'. $orgdate.'</div>'; | |
// ADD NODE URL TO DATE | |
$variables['content']['title']['0']['#markup'] = '<a href="'. $linktonode .'" class="title-date">'. $newtitle .'</a>'; | |
} | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment