I am trying to create an image gallery, using Views 3 for Drupal 7. A brief overview of what I did:
- Create custom content type for photo gallery (title and image fields
- Create View for the gallery page
- Set format to "Grid", and show to "Fields"
- Added field: "Content: Photo" (preview image style)
- Added field: "Content: Photo" (thumbnail image style)
As you can see, I have two fields with the same field so that I can have two differently sizes of each image. What I need to do, is print these images in two different places in my template.
This is my views-view-grid--gallery.tpl.php
:
<table>
<?php foreach ($rows as $row_number => $columns): ?>
<tr>
<?php foreach ($columns as $column_number => $item): ?>
<td>
<?php print $item; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
I want to be able to do something like this:
<table>
<tr>
<?php // foreach ?>
<td>
<?php // print preview image ?>
</td>
</tr>
</table>
<div class="thumbnails">
<?php // foreach ?>
<?php // print thumbnail image ?>
</div>
I have tried a multitude of things, but I can only make $item
print either one of the images, or both of the images. Since only the final, HTML-formatted image is returned, I can't figure out how it is possible to split it up.
Thanks much in advance!
$item
in different places in grid.tpl.php. I was able to only show one of the fields, but I need to show one field inside a table, and the other field inside a div outside of the table. How can I achieve this? Fields just passes back plaintext, not an array or anything.$item
contains the HTML content for the whole row, there is no way to separate it unless I manipulate the string... and there has to be a better solution than that. Do you mind showing an example snippet?