2013-05-02 219 views
2

我在Cakephp 2.1.3中遇到了一些小问题。 现在我必须使用:如何更改cakephp视图中的默认标记路径

<td background="../../img/login25.png" width="22" height="15"></td> 

我需要设置的路径为根目录在我看来,所有的标签。 我怎样才能改变路径,以便在我的意见,这样我可以使用:

<td background="login25.png" width="22" height="15"></td> 

可以有一个人告诉我们在哪里以及如何我能做到这一点? 我看了几个小时,但我能找到的是$ this-> Html功能等的路径。 谢谢

回答

0

发现:

<td background="<?php echo $this->webroot; ?>img/login25.png" width="22" height="15"></td> 
3

Erk ...我可以建议一种替代方法,并使用样式表中的CSS设置背景图像?然后路径将与样式表位置相关。

'背景'不是td元素的有效属性。

我甚至不会问你在用什么表格! ;-)

+0

THX但不是那问题,路径是在CSS文件中是相同的。在我的CSS里面是使用背景:url(“../../ img/b_grijs_a.png”);我需要背景:url(“b_grijs_a.png”);我需要设置路径 – Leendert 2013-05-02 10:49:45

+0

我无法理解你为什么'需要'这个?我认为你的意思是说,如果你以某种方式写下你的背景,那么你的背景是有效的,但是为什么你要按照目前没有的方式写下来,你的要求显然没有意义? – toby1kenobi 2013-05-02 10:59:23

+0

应用程序有时位于根目录下,有时位于一个或多个目录深处:应在所有情况下正确引用图像。 – Leendert 2013-05-02 11:28:24

0
use css code to call file in td with id or class. 


<td class="myimage" width="22" height="15"></td> 

use the css code bellow in .css file you are calling or create css file and save to app/webroot/css/ directory. 

.myimage { 

    background: url("pathtoimgfolder/b_grijs_a.png"); 

} 
For Example : I want to use image from app/webroot/img/a.png 
so I am using : 

.myimage { 
    background: url("../img/a.png"); 
} 

:) 编码快乐