(Apologies for posting this here, and if people think this should be deleted, please do.
I posted this question on stackoverflow, having completely forgotten this forum, which of course is more appropriate for a Magento question. I'd prefer to move it here but... how?!
In order to keep only one version, I've posted the link to it here.
Btw, I found an answer although I'm sure it can be improved.)
I want my main menu to not include any categories that are empty. I've done this for the layered navigation very easily in the relevant phtml file by using
However, for the navigation menu, I'm finding it impossible to do this as easily (I have seen the Prattski example but it does seem rather OTT).
The main menu seems to be built in
Mage_Page_Block_Html_Topmenu.php, specifically in the function
_getHtml. This gets all the children in the menu and if I try something like
$child->getId(), I get something like
It doesn't seem like I'm too far from being able to use
getProductCount() and so test if it's more than zero.
Is it possible to do this? Can somebody point me to how?
If I can, I'll extend the class with my version.