Zend Framework in a subfolder, but images taken from site root

丶灬走出姿态 提交于 2020-01-26 02:55:07

问题


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 add
resources.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!