Zend Framework:如何从 HeadLink 帮助程序中取消设置一个样式表
我在 Controller init() 中有一个常见样式列表:
$this->view->headLink()->setStylesheet('/style/style.css');
$this->view->headLink()->appendStylesheet('/style/style2.css');
$this->view->headLink()->appendStylesheet('/style/style3.css');
$this->view->headLink()->appendStylesheet('/style/forms.css');
$this->view->headLink()->appendStylesheet('/style/ie_patches.css','all','lte IE 7');
我需要的是稍后在该控制器的某个操作中从堆栈中删除其中一个样式表的方法。
感谢您的帮助, 请原谅我的英语
I have in Controller init() a list of common styles:
$this->view->headLink()->setStylesheet('/style/style.css');
$this->view->headLink()->appendStylesheet('/style/style2.css');
$this->view->headLink()->appendStylesheet('/style/style3.css');
$this->view->headLink()->appendStylesheet('/style/forms.css');
$this->view->headLink()->appendStylesheet('/style/ie_patches.css','all','lte IE 7');
what I need is the way to remove one of the stylesheets from the stack later in one of the action of this controller.
Appreciate your help,
excuse my English
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
或者您可以使用
要找出 offsetToBeRemoved 您可以获取迭代器(
$this->view->headLink()->getIterator()
)或容器$this ->view->headLink()->getContainer()
),循环遍历它并获取您感兴趣的密钥。OR you can use
To find out the offsetToBeRemoved you can either get the iterator (
$this->view->headLink()->getIterator()
) or the container$this->view->headLink()->getContainer()
), loop thru it and get the key you're intrested in .例如,如果您想删除 '/style/style2.css',您可以在操作中执行如下操作:
这是有效的,因为容器(即
Zend_View_Helper_Placeholder_Container
的实例)扩展了 ArrayObject。这意味着您可以像使用数组一样操作 headLink 元素。希望这有帮助。
For example, if you want to remove '/style/style2.css' you can do in an action as follows:
This works because the container (i.e. instance of
Zend_View_Helper_Placeholder_Container
) extends ArrayObject. This means that you can manipulate your headLink elements as if you were using an array.Hope this helps.
您还可以像这样设置空容器:
You can also set empty container like this: