Return to Snippet

Revision: 59761
at September 28, 2012 12:32 by thisisjamessmith


Initial Code
{!-- template URL: /products/category/{category_name} --}

{!--  ============================================
store item rows, pagination & item-count data for use later
================================================== --}
{exp:stash:set parse_tags="yes" parse_conditionals="yes"}
	{stash:results_rows}
		{exp:channel:entries channel="products" disable="categories|member_data" limit="10" paginate="both"}
			{paginate}{stash:pagination}<p>Page {current_page} of {total_pages} pages {pagination_links}</p>{/stash:pagination}{/paginate}
			{stash:all_items}{absolute_results}{/stash:all_items}		   	
			{if count == 1}{stash:first_item}{absolute_count}{/stash:first_item}{/if}
			{if count == total_results}{stash:last_item}{absolute_count}{/stash:last_item}{/if}
		   		
			{!-- build up the result rows ========================= --}
			<tr>					
				<td>{product_sku}<input type="hidden" name="entry_id[{count}]" value="{entry_id}" /></td>
				<td>{title}</td>				
				<td>{if product_price}{product_price}{if:else}TBC{/if}</td>
				<td>
					<label for="quantity">Quantity</label>
					<input id="quantity" type="text" name="quantity[{count}]" />
				</td>
			</tr>
		{/exp:channel:entries}
	{/stash:results_rows}
{/exp:stash:set}

{!--  ============================================
 build up the final 'content' variable using data 
 stored above, ready for output by the View template
================================================== --}

{exp:stash:set name="content"}
	{exp:channel:category_heading channel="products"}
	    <h1>{category_name}</h1>
	    {if category_description}<p>{category_description}</p>{/if}
	{/exp:channel:category_heading}
	
	{exp:stash:get name="pagination"}
	<p><em>Displaying items {exp:stash:get name="first_item"} to {exp:stash:get name="last_item"} of {exp:stash:get name="all_items"}</em></p>
	
	{exp:cartthrob:multi_add_to_cart_form return="..."}
		<table id="product-list">
			<tr>
				<th>Code</th>
				<th>Name</th>
				<th>Price</th>
				<th>Quantity</th>
			</tr>
			{exp:stash:get name="results_rows"}
		</table>			
		<input type="submit" value="Add all to order form" />
	{/exp:cartthrob:multi_add_to_cart_form}
	
	{exp:stash:get name="pagination"}
{/exp:stash:set}

{embed='site/view'}

Initial URL


Initial Description
A nice DRY way of using Stash for EE pagination

Initial Title
ExpressionEngine pagination + Stash + CartThrob

Initial Tags


Initial Language
HTML