Created
June 4, 2014 01:25
-
-
Save mglaman/5d0a10de68b3e23a391c to your computer and use it in GitHub Desktop.
Fancy article tag formatting. Expects "field_tags" to exist and a term reference field.
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
<?php | |
// Voila! $submitted now has date and tags. | |
?> | |
<p class="submitted"><?php print $submitted; ?></p> |
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
<?php | |
function glamanate_preprocess_node(&$variables) { | |
$node = $variables['node']; | |
$date = format_date($variables['created'], 'published'); | |
$variables['submitted'] = t('@date', array('@date' => $date, '!author' => $variables['name'])); | |
//Find out the tags | |
if (isset($node->field_tags) && $variables['page']) { | |
$article_field_tags = field_get_items('node', $node, 'field_tags'); | |
$article_tags = array(); | |
if(!empty($article_field_tags)) { | |
foreach($article_field_tags as $tag) { | |
$tag_link = t('<a href="@url" title="View articles about @tag">@tag</a>', | |
array('@url' => url('taxonomy/term/'.$tag['tid'], array('absolute' => true)), '@tag' => $tag['taxonomy_term']->name)); | |
$article_tags[] = $tag_link; | |
} | |
$article_tags_inline =implode(', ', $article_tags); | |
$variables['submitted'] .= " | tags: " . $article_tags_inline; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment