Hide empty autonavs

Permalink
Hey! I have an extra autonav called Sub-Nav on EVERY page in my site, so if the page "gets children" the children automatically shows up in Sub-Nav.

Now, is there a way to hide the <ul id="subnav"></ul> if there is no <li> inside it? This is only because I want my site to validate as xhtml strict.

Thank you!

 
xandre replied on at Permalink Reply
Now I'm producing like my fifteenth C5-based website and I still have this problem. Is there a way to hide these empty, ugly <ul>'s until someone fill them up?

I've been experimenting with if "($_c->getNumChildren() == 1)" but I don't get it to work as it should.

Thanks in advance,
Alejandro
nforcer replied on at Permalink Reply
nforcer
Same problem here...
Any ideas are appreciated.

Regards,
André
okhayat replied on at Permalink Reply
okhayat
Is this extra <ul> added by C5 or manually by you?
hayesr replied on at Permalink Reply
hayesr
This is what worked for me:

<?php /* top of page */
$subnav = new Area('Sub Nav');
?>
<?php /* later on page*/ if( $subnav->getTotalBlocksInArea($c) > 0 || $c->isEditMode() ): ?>
<ul id="subnav"> <?php $subnav->display($c); ?> </ul>
<?php endif; ?>


$c->getNumChildren counts up all the blocks in the collection; use the getTotalBlocksInArea method on the Area instance instead.