moonbeetle
5/24/2012 - 2:42 PM

EE-Stash-ZURBFoundation-block-grid-images

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"}