So basically i want to add a link to original node around each row in views. I have added the following code to the style and row template override in views. Both come up with the same result.

<?php $image = file_create_url($row->field_field_display_image[0]['rendered']['#item']['uri']); ?>
<a href="www.google.com"/>
  <div class="block__inner" style="background-image: url('<?php echo $image; ?>');">
    <?php foreach ($fields as $id => $field): ?>
      <?php if (!empty($field->separator)): ?>
      <?php print $field->separator; ?>
    <?php endif; ?>
  </div>
</a>

Now the issue that i am having is that the link is added to each field element that is outputted for some reason, and not just the link around the whole row and each field.

I am aware this can be done using jQuery but surely this should work regardless.

Comments

ColdSun’s picture

I'm having a similar issue when attempting to do this. The only difference that I'm experiecing is Drupal auto closing the link each time before printing the fields.

*Added:
Fixed my issue by making sure my image field stripped all html besides the img tag. Apparently allowing it to handle itself was causing an auto-closing of my links as well. Be sure to do the same to title as well (preventing it from creating a link and stripping the html)