0

I have created a Content Type called "Happy Days". I have created a field in that called "subtitle".

In my template "page--happy-days.tpl.php", I want the field "subtitle" to show wrapped in an tag. I attempted:

<h2><?php print render($content['field_subtitle']); ?></h2>

but no luck. Any help would be appreciated.

4 Answers 4

1

I assume you cleared the cache. Your issue is page--content-type.tpl.php override not working. Try to suggest theme hook in THEME_preprocess_node.

Furthermore you need to theme nodes of Happy Day content type, so you must use node--CONTENT_TYPE.tpl.php. For more information visit Theming nodes by content type page.

1

I think your problem is that you are using render() function. This function provides output with already assigned style. So that's why you can't see your changes.

0

You can use Fences module to change wrapping tags for fields

Fences is a an easy-to-use tool to specify an HTML element for each field. This element choice will propagate everywhere the field is used, such as teasers, RSS feeds and Views. You don't have to keep re-configuring the same HTML element over and over again every time you display the field.

enter image description here

0

you can check specific path of field using devel using dsm(*********['field_subtitle']); or check this link https://www.drupal.org/node/316688

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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