I just cant figure it out. How can change the title output of a term? I have a content type which displays the selected terms. The term is displayed as a link. How can I change this:
<div class="field-item even">
<a href="/category/fe-sub">FE-Sub</a>
</div>
to something like this:
<div class="field-item even">
<a href="/category/fe-sub">
<strong>FE-Sub</strong>
</a>
</div>
Edit: I tried it out with mymodule_preprocess_field(&$variables)
but you may not enter html, it will print "-Element
function proposals_preprocess_field(&$variables) {
if (isset($variables) && isset($variables['items']['0']['#options']['entity_type']) && $variables['items']['0']['#options']['entity_type'] == 'taxonomy_term') {
$variables['items']['0']['#title'] = '<b>'.$variables['items']['0']['#title'].'</b>';
}
}
renders link text:
<strong>term title</strong>
instead of term title
EDIT: here is how i made it work: in your template.php:
function yourtheme_field__taxonomy_term_reference($variables) {
$output = '';
// Render the label, if it's not hidden.
if (!$variables['label_hidden']) {
$output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
}
// Render the items.
$output .= ($variables['element']['#label_display'] == 'inline') ? '<ul class="links inline">' : '<ul class="links">';
foreach ($variables['items'] as $delta => $item) {
// allow html
$item['#options']['html'] = TRUE;
// set html
$item['#title'] = '<span class="label label-info">'.$item['#title'].'</span>';
$output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
}
$output .= '</ul>';
// Render the top-level DIV.
$output = '<div class="' . $variables['classes'] . (!in_array('clearfix', $variables['classes_array']) ? ' clearfix' : '') . '"' . $variables['attributes'] .'>' . $output . '</div>';
return $output;
}