开发者

injecting magento block to head via observed event

what magento frontend events can should I observe if I want the chance to inject b开发者_开发知识库locks 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.


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!


I appreciate the plug on the blog, but clockworkgeek is correct. The best way to accomplish this is to use a layout file to add the blocks you need. It is also possible for those blocks to change their own rendering behavior based on arbitrary code.

If there is a reason why you cannot use layouts, please elaborate a bit in your question and we'll be happy to help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜