0

I have a view which displays products. The fields shown are altered via hook, and I want to add <div> and <h3>, when I find an appropriate field value. (I tried with adding style to the field in the UI, but the logic is somehow convoluted, so I would need to hard-code it.)

I need to encapsulate a complete row inside a <div> when some field has some value. I have tried with views-view-fields.tpl.php and views-view-unformatted.tpl.php, but they seem not to "talk to each other", so I am failing miserably. Maybe should I approach by using views_view_result() and building the HTML myself?

2 Answers 2

0

To theme/design the complete row, you need to use Style output template file.

Click on Theme: Information in your view, in pop-up see the last file in Style output section. Copy the name and create file with same name and save this file at sites/all/themes/YOURTHEME/templates.

Then click on Style output, copy the code and paste into the newly created file. In this file, you can add your own HTML display the result.

Hope this helps.

Thanks

0

If you want to design the complete Row try Row Style Output which you found inside Theme Information

Try to create a file views-view-fields--view-name.tpl.php inside the themes/template folder and copy paste the content from views-view-fields.tpl.php file and design the view page yourself.

Thanks

1
  • Well, the theory is good, but the problem is that we have two separated files: one for each row of data, and the other file for each field in the row. I don't see that I can access to the data of one of the files from the other file, which is what is causing me the problems. Example: add in the view a field of taxonomy. Then in the tpl.php, just show the first instance of the taxonomy, and encapsulate all the rows of the same taxonomy in the same div.
    – Cesar
    Aug 17, 2016 at 8:14

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.