Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

injecting magento block to head via observed event

what magento frontend events can should I observe if I want the chance to inject blocks to the ("head" block) ?

and while in the observer's code, how do I check if the current layout has some handle (e.g. not_logged_in) set.

like image 229
epeleg Avatar asked Feb 15 '11 12:02

epeleg


1 Answers

Give the

controller_action_layout_generate_blocks_after

event a try. The Layout object and its child blocks should be instantiated by the point that event fires.

There's only ever one Layout object, and you can grab the handles in play with

// get the layout->get the updates manager->get the handles
$handles = Mage::getSingleton('core/layout')->getUpdate()->getHandles();
var_dump($handles);

If you're working on front-end code and trying to stick to magento conventions, it's probably better to add a layout.xml file to your module, and use the layout file to add your blocks. It's less fun than figuring out something new though!

like image 113
Alan Storm Avatar answered Nov 04 '22 01:11

Alan Storm