Zend Framework 布局中的图像 [英] images in Zend Framework layout

查看:28
本文介绍了Zend Framework 布局中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有点迷茫,解决方案可能潜伏在我的鼻子底下,但我无法得到,如果有人可以提供帮助,请想一想.

I am a bit lost here, solution could be lurking under my nose but I couldn't get, thought of you guys if any one can help.

问题来了:我有 Zend Framework 标准文件布局:

Here is the problem: I have Zend Framework standard file layout:

Project
  -application
     -controllers
     -views 
     -layouts
        -scripts
           -layouts.phtml
  -library
  -public
     -images
     -index.php

现在的问题是,我在layouts.phtml中只通过images/logo.gif等引用图像,在控制器视图/images/arrow.gif中也是如此

Now The problem is, I am referencing images in layouts.phtml by just images/logo.gif etc. and same in the controller views /images/arrow.gif

如果请求很简单,那效果很好http://servername/project/controller

That works fine if the request is simple http://servername/project/controller

但是如果请求更深,比如 http://servername/project/controller/index/页/2

but if the request is more deep like http://servername/project/controller/index/page/2

图像自己坏了,他们显然无法获得路径,我注意到的是,如果我在以后的请求中,图像路径将是 http://servername/project/controller/index/page/2/images/logo.gif 里面没有,图片在公开/图片中

the images break theirselves, they clearly can't get the path, what I am noticing is, if I am on later request, the image path will be http://servername/project/controller/index/page/2/images/logo.gif which is not there, the image is in public/images

我的理解是(我也用谷歌搜索了一下)框架知道默认的 public 并且总是将图像路由到 public/images.但是,这是行不通的.我是否必须添加一些重写规则或什么?

My understanding was (and I have googled it a bit as well) framework knows the default public and will route the images to public/images always. However, this is not working. Do I have to add some re-write rule or something?

有人可以帮忙吗?我将不胜感激!

Can anyone help please? I will be grateful!

推荐答案

有时候你应该先问问坐在你旁边的人!

Sometimes you should first ask the person sitting next to you!

解决办法如下:

<?=$this->baseUrl('images/logo.gif')?>

进一步调查后编辑

为了记录和帮助他人:如果您正确配置了 DocumentRoot,您可以像在非 Zend 框架环境中通常那样访问公共图像文件夹.我只在我的 httpdconf 中创建了一个虚拟目录,而如果您不创建 VirtualHost 并且不将 DocumentRoot 给它,而您的文件也不在默认的 htdocs 目录中,请期待这个问题.请参阅以下 URL 中的创建虚拟主机标题:http://framework.zend.com/manual/en/learning.quickstart.create-project.html 就可以解决问题!

For record and to help others: You can access images folder in public as you normally would in non Zend framework environment if you have configured your DocumentRoot properly. I only made a virtual directory in my httpdconf while if you do not create a VirtualHost and do not give DocumentRoot to it while your files are also not in default htdocs directory, expect this problem. See Create a Virtual Host heading in following URL: http://framework.zend.com/manual/en/learning.quickstart.create-project.html and that will solve the problem!

这篇关于Zend Framework 布局中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆