2009年9月16日星期三

[fw-mvc] Zend_Controller_Plugin_Abstract how to get stylesheet links

Hi

I want to load a css/js file dynamically so I ended up with this code

 public function postDispatch(Zend_Controller_Request_Abstract $request)     {         if (!$request->isDispatched()) {             return;         }         $controller = $request->getControllerName();        // ensure we don't add a link that already exists         $currentLinks = array();         var_dump(count($this->_view->headLink()));         foreach($this->_view->headLink() as $link)         {             if($link->rel == "stylesheet") {                 $currentLinks[] = $link->href;             }          }          // screen         $file = $this->_view->baseUrl() . '/res/css/' . $controller . '.css';         if (file_exists($file)) {             $url = $this->_view->baseUrl() . '/res/css/' . $controller . '.css';             if(!in_array($url, $currentLinks)) {                 $this->_view->headLink()->appendStylesheet($url , 'screen,projection');             }        }     } 

but I can't manage to count the existing links

Can you help me, please ?

Thanks in advance

Bye



View this message in context: Zend_Controller_Plugin_Abstract how to get stylesheet links
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: