问题
I have a dev project setup in a subfolder on my testing machine and it must stay there. However all the Zend frameworks views are linked to server root.
CSS are linked like:
<link type="text/css" href="<?php echo $this->baseUrl('/css/frontend.css') ?>" rel="Stylesheet" />
Which must be stayed this way, but it should link to
localhost/a/b/c/prj1/css/frontend.css
How can I setup a global subdirectory for this?
回答1:
You need to addresources.frontController.baseUrl = "/a/b/c/prj1"
to your configuration.
This will set the baseurl wher to link to.
Be aware the $this->headLink()
helper isn't aware of the baseUrl (probably bcs of bc).
To make it work use either:$this->headLink()->appendStylesheet($this->baseUrl('/css/frontend.css'));
or$this->headLink()->appendStylesheet($this->baseUrl().'css/frontend.css');
depending on what you feel more comfortable with
Edit:
updated according to comments
回答2:
i am not sure if i understand it clearly but try to :
if you are on linux :
don't edit the code and symlink
to folder /images/
to /a/b/c/prj1/images/
update
form your comments with samual :
you can use something like :
<?php
$view->headLink()->appendStylesheet($this->baseUrl("css/reset.css"))
->appendStylesheet($this->baseUrl("css/text.css"))
->appendStylesheet($this->baseUrl("css/960.css"))
->appendStylesheet($this->baseUrl("css/demo.css"));
echo $this->headLink();
?>
回答3:
Why do you want it in a subdirectory of your project?
Your landing page when going to the url should point to the public folder. This is were all css/js/images should be placed. Your other project files should be set with the right permissions for security.
Of course it's possible to set the css folder with different security settings because it's in your project folder but I don't see the point of doing it that way.
来源:https://stackoverflow.com/questions/4646000/zend-framework-in-a-subfolder-but-images-taken-from-site-root