1

I have created a view for content type xyz and added fields like title, body,image,designation, etc.

I want to enclosed every single field of view in html structure, so that I can see all titles in red color, all body fields in blue color, same for other fields.

what's the best approach to do this?

Edit:

Is it possible to render fields in a way like shown :

<div class = 'field1'><?php print render($view['field1']); ?></div>
<div class = 'field2'><?php print render($view['field2']); ?></div>
<div class = 'field3'><?php print render($view['field3']); ?></div>
<div class = 'field4'><?php print render($view['field4']); ?></div>

in view custom template file??

1

In your view, click on your field, then click on STYLE SETTINGS

  • Checkmark Customize Field HTML, select DIV.

  • Give it a class name, Ex: cool

  • Uncheck Add default classes, that's just extra markup that you don't need.

Then in your theme's .css file add

If your title field is a link put

.cool a{ color: red; }

If your title field is NOT link (you have link this field to the original piece of content unchecked) put

.cool { color: red; }

enter image description here

0

Open your view and open the group "advanced". Now you should click on "Theme: Information".

You will see a couple of template files, that are used by your view. The templates are grouped by the view style and sorted from the most general template to most specific template.

Now you choose the desired template and copy it into to your template folder and make your modifications.

  • Is it possible to render fields in a way like shown : <div class = 'field1'><?php print render($view['field1']); ?></div> <div class = 'field2'><?php print render($view['field2']); ?></div> <div class = 'field3'><?php print render($view['field3']); ?></div> <div class = 'field4'><?php print render($view['field4']); ?></div> : – Sugandh Khanna Feb 2 '16 at 8:34
  • I have created a view for content type xyz with fields F1, F2,F3,F4. I open the group "advanced", clicked on "Theme: Information". There are couple of template files, that are used by view. I chosen the desired template and copy it into to the template folder. Now, from views module, in theme folder, I opened views-view-grid.tpl.php and copy the content of this file to the file I have created in my template folder. But output is not coming in grid format. Is there any way to customize the fields of view in html structure? – Sugandh Khanna Feb 2 '16 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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