Cybercampbell
Cybercampbell

Reputation: 2606

Drupal 7 access field collection data in views

I have a field collection called field_logo_logos.

There are 2 fields within:

field_logo_image and field_logo_link

In views I can get the data and it comes out like this:

<div typeof="" about="/field-collection/field-logo-logos/24" class="entity entity-field-collection-item field-collection-item-field-logo-logos clearfix">
  <div class="content">
    <div class="field field-name-field-logo-image field-type-image field-label-hidden view-mode-full">
      <div class="field-items">
        <figure class="clearfix field-item even"><img width="222" height="57" title="title" alt="alttag" src="http://link/to/my/image.png?itok=1wgQypF6" class="image-style-footer-logo" typeof="foaf:Image"></figure>
      </div>
    </div>
    <div class="field field-name-field-logo-link field-type-link-field field-label-hidden view-mode-full">
      <div class="field-items">
        <div class="field-item even">http://www.mylink.com/</div>
      </div>
    </div>
  </div>
</div>

but how do I override this so I can change it to be like this:

<div class="footer-logo">
    <a href="http://www.mylink.com/" target="_blank">
        <img width="222" height="57" title="title" alt="alttag" src="http://link/to/my/image.png?itok=1wgQypF6" class="image-style-footer-logo" typeof="foaf:Image">
    </a>
</div>

I know how to do this with ordinary fields with tokens within views or in a template override but field collections seem to work differently.

Any advise will be very much appreciated.

C

Upvotes: 1

Views: 2041

Answers (1)

trackleft
trackleft

Reputation: 11

You can't do this with the current iteration of field collections.

Here's a post, they say they will allow better templating in version 2.x

https://drupal.org/node/1157794

You could always patch, but nobody ever recommends that.

Upvotes: 1

Related Questions