{if !empty($categories)} {$depth = -1} {foreach $categories as $category} {if $category.depth < $depth} {section name="end-category" loop = $depth - $category.depth} {/section} {$depth = $category.depth} {/if} {if $category.depth == $depth}