1

I want to wrap h2 tags around a 'content type' text field (the field "product_title"), as a default setting, that the user cannot change.

I have tried to add this snippet in the file template.php in my theme:

function mytheme_preprocess_field(&$vars) {
if($vars['element']['#field_name'] == 'field_produktnamn'){
    $vars['items']['0']['#markup'] = '<h2>This works</h2>';
}

}

But I can't figure out how to keep the original field content. I only want to add h2 tags, not replace the text content.

Or maybe I should go about this another way?

1 Answer 1

1

try using this instead:

$vars['items']['0']['#prefix'] = '<h2>';
$vars['items']['0']['#suffix'] = '</h2>';
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.