Zend Framework在子文件夹中,但是从站点根目录获取的图像
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?
我的测试机上的子文件夹中有一个开发项目设置,它必须保留在那里。 然而,所有Zend框架视图都链接到服务器根目录。 p>
CSS链接如下: p>
&lt; link type =“text / css“href =”&lt;?php echo $ this-&gt; baseUrl('/ css / frontend.css')?&gt;“ rel =“样式表”/&gt;
code> pre>
必须以这种方式保留,但它应链接到 p>
localhost / a / b / c /prj1/css/frontend.css
nn我如何为此设置一个全局子目录? p>
div>
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
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();
?>
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.