0

I have an entity reference field that is being handled by Display Suite. Even when setting the field template to expert, I can't completely strip away the default classes. The markup still has a div wrapper like so:

<span class="field-content">
  <div about="/products/chicken-breast-tenderloins" typeof="sioc:Item foaf:Document" class="ds-1col node node-product node-promoted node-teaser contextual-links-region view-mode-teaser clearfix">
    <div class="contextual-links-wrapper contextual-links-processed">
      <a class="contextual-links-trigger" href="#">Configure</a>
      <ul class="contextual-links">
        <li class="node-edit first"><a href="/node/37/edit?destination=node/23">Edit</a></li>
        <li class="node-delete"><a href="/node/37/delete?destination=node/23">Delete</a></li>
        <li class="manage-display last"><a href="/admin/structure/types/manage/product/display/teaser?destination=node/23">Manage display</a></li>
      </ul>
    </div>  
    <a href="/products/chicken-breast-tenderloins">Chicken Breast Tenderloins</a>
  </div>
</span>

Is there any way to remove those classes? Like maybe using a preprocess function or something?

1

Generally: You could modify the display of the content type referenced by the Entity reference field. There you can use Display suite again for formatting the fields of the referenced content type and have it styled your way.

Especially, regarding this:

<div class="contextual-links-wrapper contextual-links-processed">
  <a class="contextual-links-trigger" href="#">Configure</a>
  <ul class="contextual-links">
    <li class="node-edit first"><a href="/node/37/edit?destination=node/23">Edit</a></li>
    <li class="node-delete"><a href="/node/37/delete?destination=node/23">Delete</a></li>
    <li class="manage-display last"><a href="/admin/structure/types/manage/product/display/teaser?destination=node/23">Manage display</a></li>
  </ul>
</div>

There is an option "Display Links" on the Rendered Entity. If you uncheck this, you can get rid of this code. This is done in the content type where the Entity Reference field is included, not in the referenced conten type.

If you want to change this:

<div about="/products/chicken-breast-tenderloins" typeof="sioc:Item foaf:Document" class="ds-1col node node-product node-promoted node-teaser contextual-links-region view-mode-teaser clearfix">

Go to the content type you are referencing and check the display. It seems you are using the 1 Col Display, so you can use ds-1col.tpl.php template. There you can change the classes.

  • Actually that part isn't the part I want to get rid of. It's this line: <div about="/products/chicken-breast-tenderloins" typeof="sioc:Item foaf:Document" class="ds-1col node node-product node-promoted node-teaser contextual-links-region view-mode-teaser clearfix"> – huijing Jan 4 '16 at 10:00
  • Then look at what I have written at generally in first paragraph. Go to the content type you are referencing and format display there. – Stefan Korn Jan 4 '16 at 10:18
  • Ah, you're right. I changed the content type I was referencing to use the Reset layout. All is good now, thanks for this. – huijing Jan 5 '16 at 2:11

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.