Skip to content

Instantly share code, notes, and snippets.

@mrkurt
Created February 6, 2009 21:53
Show Gist options
  • Save mrkurt/59639 to your computer and use it in GitHub Desktop.
Save mrkurt/59639 to your computer and use it in GitHub Desktop.
<mt:SetVarTemplate name="main_menu">
<mt:CategoryBasename default="no-cat" separator="-" setvar="tl_basename" /><!-- <mt:var name="tl_basename" /> -->
<ul id="primary-navigation">
<li<mt:if var="tl_basename" eq="no-cat"> class="current-selection"</mt:if>><a href="<mt:BlogURL />">All</a></li>
<li<mt:if var="tl_basename" eq="apple"> class="current-selection"</mt:if>><a href="<mt:BlogURL />apple/">Apple</a></li>
<li<mt:if var="tl_basename" eq="business"> class="current-selection"</mt:if>><a href="<mt:BlogURL />business/">Business</a></li>
<li<mt:if var="tl_basename" eq="gadgets"> class="current-selection"</mt:if>><a href="<mt:BlogURL />gadgets/">Gadgets</a></li>
<li<mt:if var="tl_basename" eq="gaming"> class="current-selection"</mt:if>><a href="<mt:BlogURL />gaming/">Gaming</a></li>
<li<mt:if var="tl_basename" eq="hardware"> class="current-selection"</mt:if>><a href="<mt:BlogURL />hardware/">Hardware</a></li>
<li<mt:if var="tl_basename" eq="microsoft"> class="current-selection"</mt:if>><a href="<mt:BlogURL />microsoft/">Microsoft</a></li>
<li<mt:if var="tl_basename" eq="open-source"> class="current-selection"</mt:if>><a href="<mt:BlogURL />open-source/">Open Source</a></li>
<li<mt:if var="tl_basename" eq="science"> class="current-selection"</mt:if>><a href="<mt:BlogURL />science/">Science</a></li>
<li<mt:if var="tl_basename" eq="tech-policy"> class="current-selection"</mt:if>><a href="<mt:BlogURL />tech-policy/">Tech Policy</a></li>
<li id="primary-navigation-more">
<a id="primary-navigation-more-link" href="#">More</a>
<ul>
<li><a href="<mt:BlogURL />media/">Media</a></li>
<li><a href="<mt:BlogURL />software/">Software</a></li>
<li><a href="<mt:BlogURL />security/">Security</a></li>
<li><a href="<mt:BlogURL />staff/">Staff</a></li>
<li><a href="<mt:BlogURL />telecom/">Telecom</a></li>
<li><a href="<mt:BlogURL />web/">Web</a></li>
</ul>
</li>
</ul>
</mt:SetVarTemplate>
<mt:Ignore>Cats that should appear on the secondary menu for "All"</mt:Ignore>
<mt:var name="tl_submenu_cats" value="(news|guides|reviews|features)" />
<mt:Ignore>--------------------------------------
Sets the proper context for the primary category.
Options:
1) No current category, no context
2) Current category, sets TopLevelParent context
3) Current news/guides/reviews, uses no context
-------------------------------------------------</mt:Ignore>
<mt:var name="use_category_context" value="0" />
<mt:if tag="CategoryID">
<mt:CategoryID setvar="current_category_id" />
<mt:var name="use_category_context" value="1" />
</mt:if>
<mt:HasNoParentCategory>
<mt:if tag="CategoryBasename" like="$tl_submenu_cats"><mt:var name="use_category_context" value="0" /></mt:if>
</mt:HasNoParentCategory>
<mt:if name="use_category_context">
<mt:TopLevelParent><mt:var name="main_menu" /></mt:TopLevelParent>
<mt:else>
<mt:var name="main_menu" />
</mt:if>
<mt:section trim="1" strip_linefeeds="1">
<mt:Ignore>--------------------------------------
A template for the <li> that holds category links
-------------------------------------------------</mt:Ignore>
<mt:SetVarTemplate name="sub_cat_link">
<li<mt:If tag="CategoryID" eq="$current_category_id"> class="current-selection"</mt:If>>
<a href="<mt:CategoryArchiveLink />"><mt:CategoryLabel regex_replace="/[^\/]+\//g","" /></a>
</li>
</mt:SetVarTemplate>
<mt:Ignore>--------------------------------------
A template to build the category link and assign it to a hash
-------------------------------------------------</mt:Ignore>
<mt:SetVarTemplate name="sub_cat_builder">
<mt:var name="show_current_cat" value="1" />
<mt:unless tag="CategoryCount" gt="0"><mt:var name="show_current_cat" value="0" /></mt:unless>
<mt:if tag="CategoryBasename" eq="news"><mt:var name="show_current_cat" value="0" /></mt:if>
<mt:if tag="CategoryCount" gt="0">
<mt:CategoryBasename separator="-" trim="1" setvar="cat_key" >
<mt:var name="sub_cat_link" setvar="rendered_cat_link" />
<mt:var name="cat{$cat_key}" value="$rendered_cat_link" />
</mt:if>
</mt:SetVarTemplate>
<mt:Ignore>--------------------------------------
Gets the list of secondary categories to display
* If in a category context, shows subcats
* Otherwise, shows $tl_submenu_cats only
-------------------------------------------------</mt:Ignore>
<mt:If name="use_category_context">
<mt:TopLevelParent>
<mt:SubCategories>
<mt:var name="sub_cat_builder" />
<mt:SubCatsRecurse />
</mt:SubCategories>
</mt:TopLevelParent>
</mt:If>
<mt:Unless name="use_category_context">
<mt:TopLevelCategories>
<mt:if tag="CategoryBasename" like="$tl_submenu_cats">
<mt:var name="sub_cat_builder" />
</mt:if>
</mt:TopLevelCategories>
</mt:Unless>
</mt:section>
<ul id="secondary-navigation">
<mt:var name="delete(cat)" key="news" trim="1" />
<mt:var name="delete(cat)" key="guides" trim="1" />
<mt:var name="delete(cat)" key="reviews" trim="1" />
<mt:var name="delete(cat)" key="features" trim="1" />
<mt:loop var="cat"><mt:var name="__value__" trim="1" /></mt:loop>
</ul>
<mt:Include module="Additional Navigation" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment