[SOLVED] Logic for alternative content if menu empty

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am

[SOLVED] Logic for alternative content if menu empty

Post 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.
Last edited by Cerulean on Tue Feb 08, 2011 4:16 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Logic for inserting alternative content if menu empty

Post by Dr.CSS »

{capture assign='test'}{menu}{/capture}{if !empty($test)}
<div>
{$test}
</div>
{else}
<div>
something else
</div>
{/if}

Thanks to calguy1000...
Last edited by Dr.CSS on Tue Feb 08, 2011 6:28 am, edited 1 time in total.
Reason: to give credit where credit is due
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am

Re: Logic for inserting alternative content if menu empty

Post by Cerulean »

That is brilliant! Thanks!
Post Reply

Return to “Layout and Design (CSS & HTML)”