Search code examples
phpzend-frameworkstylesheetviewhelper

Zend Framework: How to unset the one stylesheet from the HeadLink helper


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


Solution

  • OR you can use

    $this->view->headLink()->offsetUnset($offsetToBeRemoved); // offsetToBeRemoved should be integer
    

    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 .