通过观察到的事件将 magento 块注入到头部
如果我想有机会将块注入到(“head”块),我应该观察哪些magento前端事件?
在观察者的代码中,如何检查当前布局是否设置了某些句柄(例如 not_logged_in)。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下这个
活动。布局对象及其子块应在事件触发时实例化。
只有一个 Layout 对象,您可以抓住其中的句柄。
如果您正在处理前端代码并尝试遵守 magento 约定,那么最好将一个layout.xml 文件添加到您的模块中,然后使用用于添加块的布局文件。但这并不比弄清楚新东西有趣!
Give the
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
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!
我很欣赏博客上的插件,但 Clockworkgeek 是正确的。实现此目的的最佳方法是使用布局文件添加所需的块。这些块也有可能根据任意代码改变它们自己的渲染行为。
如果您因某种原因无法使用布局,请在您的问题中详细说明,我们将很乐意为您提供帮助。
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.