<p>I tried your way (btw I got the view with
$this->_view = $layout->getView())</p>
<p>but the code doesn't work yet.</p>
<p>I'm afraid that it's no possible if you are
putting all your basic css statically in the
default layout :(</p>
<p>Just waiting may be I was wrong.</p>
<p>BYe.</p>
in
Pádraic Brady wrote:
>
> You can get the current View from the ViewRenderer helper:
>
> $view =
> Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')->view;
>
> Pádraic Brady
>
> http://blog.astrumfutura.com
> http://www.survivethedeepend.com
> OpenID Europe Foundation Irish Representative
>
>
>
>
>
> ________________________________
> From: whisher <whisher@mp4.it>
> To: fw-mvc@lists.zend.com
> Sent: Wednesday, September 16, 2009 10:20:29 AM
> Subject: [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.
>
>
> -----
> Pádraic Brady
>
> Blog: http://blog.astrumfutura.com
> Free Zend Framework Book: http://www.survivethedeepend.com
> OpenID Europe Foundation - Irish Representative
>
--
View this message in context: http://www.nabble.com/Zend_Controller_Plugin_Abstract--how-to-get-stylesheet-links-tp25468837p25471718.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论