Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Block children in Magento?

Tags:

magento

I am inside a phtml file, how can I get the list of children blocks within the current template?

like image 941
ilyes kooli Avatar asked Jun 07 '12 11:06

ilyes kooli


Video Answer


1 Answers

$children = $this->getChild();

Check the code within app/code/Mage/Core/Block/Abstract.php

public function getChild($name = '')
{
    if ($name === '') {
        return $this->_children;
    } elseif (isset($this->_children[$name])) {
        return $this->_children[$name];
    }
    return false;
}

So if no name is given, it simply returns all children.

like image 89
ilyes kooli Avatar answered Sep 23 '22 20:09

ilyes kooli