1

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:

  1. 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.
  2. 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

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?

1 Answer 1

1

It seems you are missing the Display Suite Extras submodule (ds_extras)? You can change the default field templates easily there.

From DS Extras doc:

Default Field Template

  • Default: will output the field as defined in Drupal Core.
  • Reset: will strip all HTML.
  • Minimal: adds a simple wrapper around the field.
  • Expert Field Template: gives full control over the HTML, but can only be set per field.

You can override this setting per field on the "Manage display" screens or when creating fields on the instance level.

admin/structure/ds/list/extras: enter image description here

Once the Extras submodule activated you will have control by fields. visit the CT "manage display" page and the main CT page (edit). Mode "Minimal" or "Expert" seems what you need.

3
  • Thanks for your quick response. I tried using "Reset" to remove all, but it still shows the div tags i highlighted above. Any other thoughts? Apr 21, 2016 at 0:07
  • clear cache? maybe you have to adjust every fields or another tpl than ds is used? I think you have two levels to adjust: CT (main setting & manage display pages) and also probably ithe dispay fields of Paragraphs. hope it helps
    – xaa
    Apr 21, 2016 at 14:07
  • I have cleared all cached and used "Reset" but the extra tags are still displaying Apr 28, 2016 at 20:56

Your Answer

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

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