Skip to content

Instantly share code, notes, and snippets.

@Natetronn
Created July 22, 2014 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Natetronn/3ee4ce7d8754f6abf56a to your computer and use it in GitHub Desktop.
Save Natetronn/3ee4ce7d8754f6abf56a to your computer and use it in GitHub Desktop.
An easy way to build Columns in ExpressionEngine using Stash - This is a 2 column, 10 item per column, with pagination example
{exp:stash:set_list name="directory" parse_tags="yes"}
{exp:channel:entries channel="profile" disable="categories|category_fields|profile_data|pagination" status="open" limit="200"}
{stash:company}{profile_company}{/stash:company}
{stash:first_name}{profile_first_name}{/stash:first_name}
{stash:last_name}{profile_last_name}{/stash:last_name}
{stash:title}{profile_title}{/stash:title}
{stash:address}{profile_address}{/stash:address}
{stash:address2}{profile_address2}{/stash:address2}
{stash:city}{profile_city}{/stash:city}
{stash:state}{profile_state}{/stash:state}
{stash:zip}{profile_zip}{/stash:zip}
{stash:country}{profile_country}{/stash:country}
{stash:phone}{profile_phone}{/stash:phone}
{stash:email}{profile_email}{/stash:email}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:get_list name="directory" orderby="company" sort="asc" limit="20" paginate="bottom"}
{if count == 1}
<div class="column">
{/if}
<address>>
<span class="bold">{company}</span><br />
{first_name} {last_name}<br />
{title}<br />
{address}<br />
{address2}<br />
{city}, {state} {zip}<br />
{country}<br />
{phone}<br />
<a href="mailto:{email}">{email}</a>
</address>
{if '{switch="1|2|3|4|5|6|7|8|9|10"}' == '10'}</div><div class="column">{/if}
{if count == total_results}</div>{/if}
{paginate}
{if {total_pages} > 1}
{pagination_links}
<ul class="pagination">
{previous_page}
<li><a href="{pagination_url}" class="page-previous">previous</a></li>
{/previous_page}
{page}
<li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
{/page}
{next_page}
<li><a href="{pagination_url}" class="page-next">next</a></li>
{/next_page}
</ul>
{/pagination_links}
{/if}
{/paginate}
{/exp:stash:get_list}
@Natetronn
Copy link
Author

I don't know how resources intensive this is or isn't for that matter but, I do know it works great!

@Natetronn
Copy link
Author

Oh and I know the address tag isn't being used correctly. It's just for example purposes.

@Natetronn
Copy link
Author

It's be brought to my attention, in later version of EE I think starting at 2.7 (don't quote me on that) you can use the Modulus Operator for doing something similar as how I was using the switch: http://ellislab.com/expressionengine/user-guide/templates/conditionals.html#modulus-operator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment