Needs review
Project:
BlueMasters
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
5 Apr 2012 at 00:52 UTC
Updated:
5 Apr 2012 at 01:43 UTC
Hi All,
I like the bluemasters theme, however I find the themeing of taxonomy terms to be unclear, I created the following code to make the following change:
From:
Tags: XYZ XYZ
To:
Tags: XYZ | XYZ
Here's the code:
function bluemasters_field__taxonomy_term_reference($vars) {
$output = '';
// Render the label, if it's not hidden.
if (!$vars['label_hidden']) {
$output .= '<div class="field-label"' . $vars['title_attributes'] . '>' . $vars['label'] . ': </div>';
}
// Render the items.
$output .= '<div class="field-items"' . $vars['content_attributes'] . '>';
foreach ($vars['items'] as $delta => $item) {
// Set a delimiter, in this case a pipe
$delimiter = ' | ';
// If the item is the last in the array remove the pipe
if (end($vars['items']) === $item) {
$delimiter = '';
}
$classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
// Output each taxonomy term item, with the delimiter on the end
$output .= '<div class="' . $classes . '"' . $vars['item_attributes'][$delta] . '>' . drupal_render($item) . $delimiter . '</div>';
}
$output .= '</div>';
// Render the top-level wrapper element.
$tag = $vars['label_hidden'] ? 'div' : 'div';
$output = "<$tag class=\"" . $vars['classes'] . '"' . $vars['attributes'] . '>' . $output . "</$tag>";
return $output;
}Input/Comments welcome.
To use - simply add the code before the ?> in template.php you'll need to change the "bluemasters" in the function name if you have renamed the theme or created a subtheme.
To change the delimiter simply replace | with your chosen delimiter.
E.G: For a comma use: ,
Comments
Comment #1
Homotechsual commentedComment #1.0
Homotechsual commentedCorrected exposed HTML code