3

I am trying to find an existing block to call it from my template

is it possible to use something like:

    <?php var_dump( $this->getLayout()->getAllBlocks() );?>

this gives me a 505 error

Matoeil
  • 607
  • 1
  • 9
  • 23

2 Answers2

8

All the blocks in the layout are huge objects that have references to other huge objects and at one point you get a circular reference an var_dump crashes.
If you want to get the names of the available blocks do this:

var_dump(array_keys($this->getLayout()->getAllBlocks()));

then if you find the key you need you can just print it out like this:

echo $this->getLayout()->getBlock('KEY HERE')->toHtml();

You can even call the line above without knowing if the block exists but call it a little different:

if ($block = $this->getLayout()->getBlock('KEY HERE')) {
    echo $block->toHtml();
}
Marius
  • 197,939
  • 53
  • 422
  • 830
2

I hope this might help you, if you want to enlist all static blocks:

 Mage::getResourceModel('cms/block_collection')->load()->toOptionArray(); 
TBI Infotech
  • 4,788
  • 1
  • 13
  • 30