2

I have made a view named services which fetches the fields of content type services, fields name : services_text and services_image. I have made a custom tpl named views-view--services.tpl.php with my own structure and want to access fields like $row['services_text'] in for each, but it comes out as undefined index, as i can figure it out, by using var_dump, that this tpl is not getting any row rather plain html string for output so I even tried with views-view-unformatted.tpl.php, but still no use.

Kindly help.

1
  • 1
    create file using "Row style output" instead of from "Style output" Nov 2, 2015 at 13:06

1 Answer 1

1

Use views-view-fields--.tpl.php and render the field with your custom markup

For example:

<div class="product-item">
    <div class="row clearfix">
      <div class="product-image"><?php print $fields['field_images']->content; ?></div>
    </div>
    <div class="row clearfix text-center">
      <div class="product-attributes"><?php print $fields['title']->content; ?></div>
    </div>
    <div class="row clearfix text-center">
      <div class="product-attributes"><?php print $fields['title_1']->content; ?></div>
    </div>
    <div class="row clearfix  text-center">
      <div class="product-attributes price"><?php print $fields['another_field']->content; ?></div>
    </div>
</div>
0

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.