I'm having a similar problem. I'm trying to get the base url in the controller methods, by using:
Zend_Controller_Front::getInstance()->getBaseUrl();
But nothing gets returned from that method. How should I get the baseUrl in a controller (or bootstrap for another matter - didn't mean to hijack your thread David).
-Andy Daykin
From: Hector Virgen
Sent: Thursday, February 25, 2010 10:20 AM
To: David Lukas
Subject: Re: [fw-mvc] Autodetected baseUrl not available in bootstrap?
Are you using a layout? It would be easier to add your common CSS/JS to the layout script. Within the layout $this->baseUrl() should be working properly.
--
Hector
--
Hector
On Wed, Feb 24, 2010 at 11:47 PM, David Lukas <david.lukas@langfor.cz> wrote:
Hi,
I am intializing view placeholders in a bootstrap resource method like this:
protected function _initViewPlaceholders() {
$this->bootstrap("frontController");
$front=$this->getResource("frontController");
$this->bootstrap('view');
$view = $this->getResource('view');
$view->headLink()->appendStylesheet($view->baseUrl("path/to/stylesheet.css"));
$view->headScript()->appendFile($view->baseUrl("path/to/script.js"));
}
But the method does not work as expected - the style and script links have
no baseUrl prepended. When called from this method, $view->baseUrl() as well
as $front->getBaseUrl() return "/", although when called from an action
controller they return correctly autodetected baseUrl.
When I manually specify baseUrl in the config file:
resources.frontController.baseUrl = "/baseUrl"
the resource method works fine and files are linked correctly.
Which resource is responsible for injecting the autodetected baseUrl into
the front controller? Or am I missing the point completely? If yes, what is
the best practice for getting hold of the autodetected baseUrl in a
bootstrap resource method?
Thanks for any help,
David
ZF 1.10.1
--
View this message in context: http://n4.nabble.com/Autodetected-baseUrl-not-available-in-bootstrap-tp1568601p1568601.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论