0

My html code:

<div class="workList col-lg-4">
  <div class="view-back">
    <a href="" target="_blank">&rarr;</a>
  </div>
<img class="img-responsive" src="<?php print base_path(). path_to_theme();?>/assets/images/img.jpg" alt="">
</div>

In views-view-fields--name--name.tpl I'm using this code:

<div class="view-back">
    <a href="" target="_blank">&rarr;</a>
</div>
<?php print $fields['field_fieldName']->content;?>

The generated output is the following.

<div class="col-lg-4  first odd">
      <div class="view-back">
    <a href="" target="_blank">→</a>
</div>
<div>## I have to remove this div
  <img typeof="foaf:Image" src="http://localhost/Drupal/name/sites/default/files/styles/recent_work/public/img.jpg?itok=vVkU2WWt" width="390" height="250" alt="">
</div>
</div>

I have to remove the default <div> before the <img> tag.

3
  • use Java Script to remove this div instead of create new view template file. Apr 15, 2014 at 7:48
  • possible duplicate of Create template file for views block
    – Mołot
    Apr 15, 2014 at 8:04
  • For anyone reading - do not use Javascript to do this. Override the default view template to remove the wrapping div.
    – Kevin
    Oct 30, 2021 at 18:08

1 Answer 1

0

Click on field and edit settings Override style settings for field

Customize field HTML Customize field and label HTML

2
  • @ gfarishyan Thank you. Actually there is not printing an image. I am using <?php print $fields['field_fieldName']->content;?> Am I wrong??
    – yuren
    Apr 18, 2014 at 11:20
  • what is the output of print_r($fields['field_fieldName']) or even use dsm/dpm dpr if you enabled devel module ?
    – gfarishyan
    Apr 20, 2014 at 13:18

Your Answer

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

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