Page 1 of 1

[SOLVED] Logic for alternative content if menu empty

Posted: Tue Feb 08, 2011 3:35 am
by Cerulean
I have a pretty typical page layout with navigation split into a horizontal nav for top level items and then a vertical nav in a sidebar for 2nd level items. My question is: is there some sort of if/else logic I can use to display alternative content in the sidebar for top level pages that don't have children? Either in the page template (if sidebar div is empty, insert this code..., or if {menu} returns nothing, insert this code...) or in the Menu Manager template (if no list items, insert this code...)
In the Menu Manager template I tried
{if $count > 0}
...menu code
{else}
...my alternative code
{/if}

but it didn't work. Maybe someone has done this before, or can see where I'm going wrong. Thanks.

Re: Logic for inserting alternative content if menu empty

Posted: Tue Feb 08, 2011 3:42 am
by Dr.CSS
{capture assign='test'}{menu}{/capture}{if !empty($test)}
<div>
{$test}
</div>
{else}
<div>
something else
</div>
{/if}

Thanks to calguy1000...

Re: Logic for inserting alternative content if menu empty

Posted: Tue Feb 08, 2011 4:15 am
by Cerulean
That is brilliant! Thanks!