繁体   English   中英

如何在第二页上使用$ this-uri-segment

[英]How to use $this-uri-segment on the second page

我有这些页面的标题使用背景图片。 在第一页上,背景显示的图像很好,但是在第二页上显示空白的背景。

我试图将其更改为具有不同名称和目录上不同图片的segment(2) ,但它无法修复。

这是我使用的行:

style="background-image: url(public/frontend/home/title_bg/<?php echo $this->uri->segment(1)?>.jpg);">

在第一页中,我使用了$this->uri->segment(1) ,在目录中,我将该文件命名为product.jpg

我可以在第二页上使用具有相同名称和相同图片的segment(1)吗? 以及我该怎么做?

确保正确设置uri段。 看看这个Codeigniter Samaple。

http://example.com/index.php/news/local/metro/crime_is_up
The segment numbers would be this:

$this->uri->segment(1) = news
$this->uri->segment(2) = local
$this->uri->segment(3) = metro
$this->uri->segment(4) = crime_is_up 

在您的情况下,我相信您可以将功能命名为产品的控制器,并且可以得到结果。 如果您创建另一个具有相同功能名称的Controller,则可以再次使用segment(1) 建议不要执行该操作,如果您想再次调用图像到另一个函数,只需调用图像名称即可。

url(public/frontend/home/title_bg/<?php echo product.jpg);

让我知道结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM