So, the point of this article is to show how to create a completely dynamic grid-based product page using the following things.
- ExpressionEngine. This is the basis for the site itself.
- The ExpressionEngine File Module.
- The brilliant Matrix plugin by Pixel and Tonic.
- Zack Grossbart’s awesome Dynamic Grid Layout jQuery Plugin.
- The Image Sizer plugin for ExpressionEngine.
Note: Because EE isn’t free (some consider it very expensive), I’m going to make the assumption that paying USD $55 for the Matrix plugin isn’t a major problem, either.
Ok, so how do we proceed?
There are a few steps to cover off first – please make sure you’ve done these before getting stuck in.
- Setup ExpressionEngine as per your requirements. Because these settings are site-specific, I’m not going to cover EE configuration here.
- Enable the EE File module.
- Setup an upload location for the images in the product section (remember, this article is for a products page). Don’t forget to set the appropriate permissions on the upload location …
- Install and register the Matrix fieldtype.
- Install and enable the Image Sizer plugin.
- Upload some files to the products upload location. You don’t need to add captions to the files as we’ll be using Matrix for that.
Now that all the preparatory stuff is done, we can configure Matrix. The channel that has the products info must have a custom field of type ‘Matrix’. The example I’m working with is called Product Images and has three field options within the field:
- Product Image (cell type = File), called product_image – make sure the Allowed Directory is set to the name of your upload location if you want to guarantee the files end up in the right place.
- Long caption (cell type = Text), called caption.
- Short caption (cell type = Text), called short_caption.
Create a channel entry in the relevant channel and, in the “Product Images” field, create a number of Matrix rows that reference files you uploaded earlier. Make sure the Matrix rows have info in both the Caption and Short Caption columns. If you want to make absolutely sure these fields are filled in, enforce it by setting those columns to required in the Matrix configuration.
Once the entry is live, take note of the entry ID – we’ll be using it in our template.