Skip to content

Instantly share code, notes, and snippets.

@moonbeetle
Created May 24, 2012 14:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moonbeetle/2781971 to your computer and use it in GitHub Desktop.
Save moonbeetle/2781971 to your computer and use it in GitHub Desktop.
EE-Stash-ZURBFoundation-block-grid-images
{!--
Conditionally output up to three images in a Foundation block-grid
Assumptions:
* Channel "Pages" (pages)
* Custom field "cf_page_images"
* Addons : P&T Assets, Croxton's Stash, Switchee
* Assets field set to allow multiple images
* Template uses ZURB Foundation framework
* Limit is set to three images, but ZURB Foundation block-grids go up till five
--}
{exp:stash:set parse_tags="yes" replace="no" refresh="1440"}
{exp:channel:entries channel="pages" limit="1" disable="member_data|pagination|categories"}
{stash:page_images}
{!-- Conditionally output up to two images in a block grid --}
{cf_page_images var_prefix="file" limit="3"}
{if count == 1}
{exp:switchee variable = "{file:total_files}" parse="inward"}
{case value="1"}<ul class="mobile">{/case}
{case value="2"}<ul class="block-grid two-up mobile">{/case}
{case value="3"}<ul class="block-grid three-up mobile">{/case}
{/exp:switchee}
{/if}
<li>
<figure class="page_image">
<img src="{file:url}" alt="{file:title}" width="100%" />
{if file:title != ''}<figcaption>{file:title}</figcaption>{/if}
</figure>
</li>
{/cf_page_images}
</ul>
{/stash:page_images}
{/exp:channel:entries}
{/exp:stash:set}
{!-- Then output in your template with the following : --}
{exp:stash:get name="page_images"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment