0

I need to add some data- attributes and I am hoping to change it for the body and title fields on article content types. Do the title/body have tpl's that I can modify to add these? Or another method I could try? I've tried adding a field--body--article.tpl.php and it doesn't appear to work.

NOTE: This needs to be done in PHP as the search engine we're using needs it to be done server side.

1
  • You can do this by setting a view for the content type and using fields. Then use views templates for the title/body fields.
    – rachel
    Jul 11 '19 at 18:57
1

Title does not use a template, but is rendered directly in page.tpl.php by default.

Display Suite can be used to override this behavior. Many examples available. Here's one for D8, but the principal is the same in D7: https://www.webwash.net/using-display-suite-drupal-8-how-to-use-display-suite-fields/

You may also find using preprocess hooks in template.php to be useful.

https://www.drupal.org/docs/7/theming/overriding-themable-output/setting-up-variables-for-use-in-a-template-preprocess-and

Proprocess hooks give you control over the entire render pipeline, so it's hard to give better guidance without knowing more specifics of your use case.

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.