[Drupal Views] How to add an additional div tag inside a table in a Views gird view?

| | 1 min read

Drupal Views allows you to output results in a variety of formats including a grid view. There might be a situation where you would want to insert an additional div tag inside the td tag of the grid view to bring in additional styling like having a custom background color and spacing between the grid elements. You can implement this in two ways in your Drupal site. Read on to find out more.

  • The easiest solution to add the div tag would be to create a .tpl.php file for the View and add the div there.

However a template file should be left for significant modifications to the view and not just for adding a div tag. The second solution would be to rewrite the results.

  • First set the fields in the view to not display.
  • Next re-write the results in the last field including the div in which the results will be written.

Thats it. Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. Do you need professional help in building your Drupal site? We can provide a wide range of Drupal services to help you deploy your Drupal site easily and quickly. Get in touch with us to know more.