We are using a mix of Display Suite using the manage display and Paragraph Module on the content types to help control some of the output of the nodes.
One problem we are trying to resolve is how to remove the extra div tags that are generated for the fields.
The options we have tried are:
use custom module to call hook_preprocess_entity and hook_preprocess_field hooks so that we can add the div classes as needed
- PRO
- We can rewrite the output to include any classes or values we want
- Because we are using a module is that the module code can be cached
- CON
- We cannot completely control what is outputted as shown below.
- PRO
Write a paragraphs-items-pr_body_title.tpl.php file so that we can rewrite the output
- PRO
- We can control the exact output and remove the div tags outlined below
- CON
- I am learning that template files are not cacheable
- PRO
Example (issue):
<div class="field field-name-field-title field-type-text field-label-hidden">
<div class="field-items">
<div class="field-item even">
<div> /* field value */ </div>
</div>
</div>
</div>
<div class="field field-name-field-body field-type-body field-label-hidden">
<div class="field-items">
<div class="field-item even">
<div> /* field value */ </div>
</div>
</div>
</div>
Desired Scenario:
<div class="field-title">
/* title value */
</div>
<div class="field-body">
/* body value */
</div>
What is the recommended way to resolve the issue?