Magento – Get category ids by page layout name

categorylayout

I have a little problem, I don't know how to solve it. My problem is I want get category id by the page layout selection. For example from admin I have created new layout 'category-like'. just like other layouts, 1-colomn, 2-colomns-with-left-bar .. So now I want get which categories are used this layout. If two categories are used this layout mens, then I need that category id …Please help me guys..

Update:

At least please tell me, how get page layout name from category id …

Best Answer

list.phtml

Get the layout of Current Category

$yourCatId = $this->getCategoryId(); 
echo $this->getLayout()->getBlock('root')->getTemplate($yourCatId);

This is to get list of all category and there layouts:

$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('id')
->addAttributeToSelect('name')
->addAttributeToSelect('url_key')
->addAttributeToSelect('url')
->addAttributeToSelect('is_active');

foreach ($categories as $category)
{
    if ($category->getIsActive()) { // Only pull Active categories
        $entity_id = $category->getId();
        echo $this->getLayout()->getBlock('root')->getTemplate($entity_id);

    }
}
Related Topic