title: Subcategory list with Magento Flat Catalog
body: <p>I'm using the code below to get a list of categories on the same level as the current page (by listing the subcategories of this category's parent). It works great when Flat Categories are off. Once I enable Flat Categories, the H2 works correctly, but the list changes to display the <em>root's</em> subcategories instead of <em>this page's parent's</em> subcategories. What am I doing wrong, and why does it act this way?</p>
  
  <pre><code>&lt;?php
  $_category  = $this-&gt;getCurrentCategory();
  $parentCategoryId = $_category-&gt;getParentId();
  $collection = Mage::getModel('catalog/category')-&gt;getCategories($parentCategoryId);
  $helper     = Mage::helper('catalog/category');
  $parentCategory   = Mage::getModel('catalog/category')-&gt;load($parentCategoryId);
  
  ?&gt;
  &lt;h2&gt;&lt;?php echo $parentCategory-&gt;getName(); ?&gt;&lt;/h2&gt;
  
  &lt;ul&gt;
  &lt;?php foreach ($collection as $cat):?&gt;
          &lt;?php if($_category-&gt;getIsActive()): ?&gt;
              &lt;li &lt;?php
                  if ($cat-&gt;getId() == $_category-&gt;getId()) {
                      echo 'class="current"';
                  }
              ?&gt;&gt;
                  &lt;a href="&lt;?php echo $helper-&gt;getCategoryUrl($cat);?&gt;"&gt;&lt;?php echo $cat-&gt;getName();?&gt;&lt;/a&gt;
              &lt;/li&gt;
          &lt;?php endif; ?&gt;
      &lt;?php endforeach;?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Yes, I've flushed the cache and indexes.</p>