$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('level', 2) level
->addAttributeToFilter('is_active', 1)
->addAttributeToFilter('include_in_menu', 1)
->addFieldToFilter('path', array('like'=> "1/$rootid/%"))
;
foreach ($categories as $category) { yaddayadda() }
Calling this from a simple script in the shell directory leads to the correct result. I only get the categories that are active and included in the menu. But when it is called in the normal Magento Block for building the top navigation it somehow changes the attributes of the categories. It shows everyone and when I check the attributes via debugger or var_dump it says "included_in_menu" (or "is_active") is 1. But it's not! It's correctly set in the backend and getting this collection via shell it says the values are 0. I cleared the caches endless times and saved the categories multiple times.
What can possibly cause this?