I want get all used block names of current pages kindly reply me
-
1why do you need all block names ? and from where you need to get it ?– Rajeev K TomySep 16, 2014 at 10:29
-
My custom extension add block name admin– VishalSep 16, 2014 at 10:30
-
1didn't get you. Add more details to your question– Rajeev K TomySep 16, 2014 at 10:33
-
in my extension user can add product blocks like product.list,search_result_list..after that depends on adding blocks add follow next conditions..– VishalSep 16, 2014 at 10:40
Add a comment
|
2 Answers
Use this:
$blocks = Mage::app()->getLayout()->getAllBlocks();
This will give you an array with the block instances. To get only the names use this:
$blockNames = array_keys($blocks);
-
1
Magento,get list child of a block using _sortedChildren
variable of this block object
Suppose if want get all child block name of root block then
justblock from layout and fetch block and get list of child block name
:
$block = $this->getLayout()->getBlock('root');
$childBlockNameCollection=$block ->_sortedChildren;
echo "<pre>";
print_r($childBlockNameCollection);
echo "</pre>";
Do recursive function get all list of child block.