0

I'm looking for direction on how to format the field layout of a view.

Here's the layout I'm looking for:

--------------------------------------------------
| Field1     | Field2      | Field3              |
| Field4     | Field5      |                     |
--------------------------------------------------
| Body                                           |
|                                                |
|                                                |
-------------------------------------------------- 

Using the "column" selection in the table settings, I'm able to "combine" fields into a single column (i.e. Field1 and Field4), but I'm stuck on how to display the Body under all the other fields in a cell that spans the whole table.

Suggestions?

I realize there are many ways to achieve my goal, in fact I've found this video that seems to be exactly what I'm looking for, but is this an overkill?

2

For precise control over views markup I usually take a departure from typical Drupal methods. I set the view to be a table format, then create my own view template. The reason I use the table format is that it's really easy to work with and has a simple loop through each row of the results returned from the view. From there, you can create your own markup using just the field values from each row.

Check this link: https://api.drupal.org/api/views/theme!theme.inc/group/views_templates/7

Here's some shortcuts to get you started quickly. In your theme's directory, create a file called: views-view-table--NAME-OF-YOUR-VIEW.tpl.php

Inside that file, start by pasting the source from this (click View source on the page): https://api.drupal.org/api/views/theme!views-view-table.tpl.php/7

Then, clear your site's cache. Your view will now be using that new template and you can edit as required.

  • Thanks for the response. I'm not familiar (yet) with how to create custom view templates, can you direct me to an article/video or post on how that is done? – William Fields Feb 24 '15 at 20:47
  • @WilliamFields added some more detail... you're about to see some really neat parts of Drupal customization! – user5482 Feb 24 '15 at 20:50

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.