Grid Views using imagefield and multiple images
Purpose
This howto will briefly show you how to display just one image in Bonus: Grid View when you have multiple images enabled. By default, Bonus: Grid View will display all the images and break the formatting of the grid. This is undesirable, but can be fixed.
Required Modules
Views
Content Construction Kit (CCK)
Views Bonus Pack
Imagefield
Imagecache
Obligatory Disclaimer
BACK UP YOUR DATABASE. BACKUP YOUR FILES.
How To
- Enable all the required modules (you can just enable Bonus: grid view from the Views Bonus Pack).
- Site Building > Modules
- Create a content type (e.g. slideshow)
- Content Managment > Content Types
- Add Content Type
- name: SlideShow
- type: slideshow
- Save Content Type
- Add an image field to the content type
- Content Management > Content Types > Edit
- Add a field
- name: image
- Field Type: Image
- Create Field
- Configure your image field
- Configure Max Resolution, Image Path, allowable fields (i.e. alt and title)
- Enable Multiple Values
- Configure Imagecache
- The full depth of configuring imagecache is beyond the scope of this howto. See the documentation for further information
- Add a few slide show content types. Make sure to upload a few images for each node.
- Configure how the imagefield is displayed
- Content Management > Content Types > Edit > Display fields
- For the Full option select an imagecache size that you configured in an earlier step
- Grid View ignores the teaser so it doesn't matter.
- Configure a view
- Basic Information
- Site Building > Views > Add
- Name: slideshow
- Description: Grid view of slide shows
- Page
- Page: Provide Page View
- URL: slideshows
- View Type: Bonus: Grid View
- Title: My Great and Wonderful Slideshows
- Fields
- Image: Slideshow (field_slideshow_image) ---it may be named different---
- Node: title (optional step)
- Set the Image: Slideshow Handler to "Do not group multiple values"
- Set the Option as one of your imagecache presets as link
- Filters
- Node: Type is One of Slideshow
- Node: Published Equals Yes
- Node: Distinct is distinct
Bonus
You can change the number of columns that display by adding this code to the Views Arguments Code textarea. It defaults to 4 columns, you can change that to two (2) for instance.
Site Building > Views > Edit --your view-- > Arguments > Argument Handling Code
$view->gridcount = 2;