<{assign var=temp value=0}>
<{foreach item=category from=$categories}> <{assign var=temp value=$temp+1}> <{if !$indexpage}>
<{else}>
<{/if}> <{if $selected_category == $category.categoryid}>

  <{$category.name}>

<{else}>

  <{$category.categorylink}>

<{/if}>
<{$category.description}>
<{if $category.subcats}>
<{foreach item=subcat from=$category.subcats}> <{$subcat.categorylink}>   <{/foreach}> <{/if}>
<{if $temp%3 == 0}>
<{/if}> <{/foreach}>