在 Zend HeadScript 视图助手中修改堆栈
我正在尝试解决这个问题一个完全不同的角度,因为看起来我无法通过这种方式实现我的目标。
我想循环 HeadScript View Helper,并对其进行修改。 文档为此和其他一些视图助手做出了这样的声明:
HeadScript 会覆盖每个append(), offsetSet()、prepend() 和 set() 为 强制使用特殊方法 如上所列。在内部,它存储 每个项目作为一个 stdClass 令牌,其中 它稍后使用序列化 itemToString() 方法。这允许 您对以下项目进行检查 堆栈,并可选择修改这些 通过简单地修改对象来修改项目 返回。
那么,这个“返回的对象”在哪里呢?我在这里遗漏了一块拼图。
感谢您的帮助!
I am trying to attack this problem from a completely different angle, because it doesn't look like I can achieve my goal that way.
I want to loop over the item stack in the HeadScript View Helper, and make modifications to it. The documentation for this and some of the other view helpers makes this statement:
HeadScript overrides each of append(),
offsetSet(), prepend(), and set() to
enforce usage of the special methods
as listed above. Internally, it stores
each item as a stdClass token, which
it later serializes using the
itemToString() method. This allows
you to perform checks on the items in
the stack, and optionally modify these
items by simply modifying the object
returned.
So, where is this "object returned"? I am missing a piece of the puzzle here.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
Zend_View_Helper_HeadScript
的toString()
方法中,我注意到$this
上有一个foreach()
循环,所以我尝试了这确实有效。这是我编写的 HeadScript 扩展,它说明了解决方案:在
Bootstrap.php
中,以下几行指向我的助手:在我的布局中,我有这一行:
如果我的解决方案在任何方面都不清楚,让我知道,我会更新以澄清。
In the
toString()
method ofZend_View_Helper_HeadScript
I noticed aforeach()
loop on$this
, so I tried that and it worked. Here's a HeadScript extension I wrote that illustrates the solution:In
Bootstrap.php
the following lines to point to my helpers:In my layout, I have this line:
If my solution is unclear in any way, let me know and I'll update it to clarify.