0

I'm using Drupal 7, and I have a content type called Book, which consists of a picture and a title. I'm using Views (grid format) to display Books on a page, and it's working great. The only problem is that the titles always sit directly under the picture, which looks bad if the pictures are of different heights. Is there a way to horizontally align all fields within a grid?

This is what I currently have:

_____   _____   _____
|    |  |    |  |    |
|    |  |    |  |    |
|____|  |    |  |____|
title   |____|  title
        title

And this is what I want:

_____   _____   _____
|    |  |    |  |    |
|    |  |    |  |    |
|____|  |    |  |____|
        |____|  
title   title   title

I've managed to achieve this by overriding views-view-grid.tpl.php (and adding a new row to the table for each field), but was wondering if there was a better way?

Update: I'm not interested in solutions that involve changing the layout / picture sizes. This is the second time a designer has given me a PSD that leaves me facing this issue, so I'd really like to find a good solution to this exact problem!

1

If the images are of different sizes, it might look a lil sloppy. You can use CSS to set a particular height and width for all the images so that they look uniform and I guess overriding views-view-grid.tpl.php just for this is not the best way.

  • Thanks for your response, but I don't want to change the size of the images. I'm leaving the design to the designers - and this is how they want it. – jackocnr Apr 20 '12 at 8:26
0

This is the way I used to do it. http://www.advomatic.com/blogs/amanda-luker/table-free-gallery-grid-view-drupal-theming However this post is a bit dated. That said, same size images really is the way to go if you can, or set a definite height.

  • That blog post solves the slightly different problem of the alignment between rows of items. My problem is with the alignment of fields within a single row of items. – jackocnr Apr 20 '12 at 8:28

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.