Skip to content

Instantly share code, notes, and snippets.

@iainurquhart
Created February 21, 2012 09:30
Show Gist options
  • Save iainurquhart/1875423 to your computer and use it in GitHub Desktop.
Save iainurquhart/1875423 to your computer and use it in GitHub Desktop.
Stash and Taxonomy, example usage
<!--
PARENT TEMPLATE, /pages for example
-->
{exp:channel:entries limit="1" disable="member_data|pagination|categories"}
<!-- set the node -->
{exp:taxonomy:set_node tree_id="1" key="entry_id" val="{entry_id}" var_prefix="this_"}
<!-- stash the nav -->
{exp:stash:set type="snippet" name="left_navigation"}
{exp:taxonomy:nav auto_expand="yes"}
<a href="{node_url}">{node_title}</a>
{/exp:taxonomy:nav}
{/exp:stash:set}
<!-- stash the crumbs -->
{exp:stash:set type="snippet" name="breadcrumbs"}
<p>You are here: {exp:taxonomy:breadcrumbs}</p>
{/exp:stash:set}
<!-- stash the content area -->
{exp:stash:set type="snippet" name="page_content"}
<h1>{title}</h1>
{if kicker}
<div class="kicker">{kicker}</div>
{/if}
{main_content}
{/exp:stash:set}
<!-- stash the previous link -->
{exp:taxonomy:prev_node}
{exp:stash:set type="snippet" name="pagination_prev_link"}
<a href="{prev_node_url}"> &larr; {prev_node_title}</a> &nbsp; &nbsp;
{/exp:stash:set}
{/exp:taxonomy:prev_node}
<!-- stash the next link -->
{exp:taxonomy:next_node}
{exp:stash:set type="snippet" name="pagination_next_link"}
<a href="{next_node_url}">{next_node_title} &rarr;</a>
{/exp:stash:set}
{/exp:taxonomy:next_node}
{/exp:channel:entries}
<!-- embed! -->
{embed="pages/layout"}
<!--
EMBED TEMPLATE, /pages/layout
-->
{snp_head_html}
<nav>
{left_navigation}
</nav>
<article>
{breadcrumbs}
{page_content}
<!-- global variable from parent set_node is parsed early :) -->
{if this_node_has_children == 'yes'}
<h3>in this section</h3>
{exp:channel:entries fixed_order='{exp:taxonomy:get_children_ids}' dynamic='off' parse="inward"}
<a href="{exp:taxonomy:node_url entry_id='{entry_id}'}">{title}</a><br />
{/exp:channel:entries}
{/if}
{if pagination_next_link || pagination_prev_link}
<ul id="entry_pagination">
{if pagination_next_link}<li class="next">Next: {pagination_next_link}</li>{/if}
{if pagination_prev_link}<li class="prev">Prev: {pagination_prev_link}</li>{/if}
</ul>
{/if}
</article>
{snp_foot_html}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment