【发布时间】:2011-05-27 07:44:42
【问题描述】:
大家好,我正在寻求帮助以重新编写图像路径。
让我解释一下.....
假设我正在运行 2 个应用程序。 APP-A 和 APP-B。我的 APP-A 安装了一个插件,它以纯 HTML 格式生成菜单输出并保存为 HTML 文件。
我现在想将此 HTML 文件导入我的 APP=B 并将其用作它的菜单。 HTML 文件看起来像这样.....
<div class="menu">
<li class="item27 parent root" >
<a class="daddy item image subtext" href="/xyz/cms/index.php>
<span>
<img src="tmpl/abc_template/images/icons/icon.png" alt="icon1.png" />
Link 1 <em>subline</em>
</span>
</a>
</li>
<li class="item27 parent root" >
<a class="daddy item image subtext" href="/xyz/cms/index2.php>
<span>
<img src="tmpl/abc_template/images/icons/icon.png" alt="icon2.png" />
Link 2 <em>subline</em>
</span>
</a>
</li>
<li class="item27 parent root" >
<a class="daddy item image subtext" href="/xyz/cms/index3.php>
<span>
<img src="templ/abc_template/images/icons/icon.png" alt="icon3.png" />
Link 3 <em>subline</em>
</span>
</a>
</li>
</div>
我正在使用require_once('../../app-a/menu.html');将此文件导入我的APP-B
文件正常,但图像路径有问题。这些路径是相对于 APP-A 生成的,我想更改它们,以便我的 APP-B 从正确的位置获取它们。
比如我在APP-B中导入文件后,
我想在我的 APP-B 读取图像路径之前添加 ../../ 以便这些路径:
<img src="tmpl/abc_template/images/icons/icon.png" alt="icon1.png" />
<img src="tmpl/abc_template/images/icons/icon.png" alt="icon2.png" />
<img src="tmpl/abc_template/images/icons/icon.png" alt="icon3.png" />
变成这样的路径
<img src="../../tmpl/abc_template/images/icons/icon.png" alt="icon1.png" />
<img src="../../tmpl/abc_template/images/icons/icon.png" alt="icon2.png" />
<img src="../../tmpl/abc_template/images/icons/icon.png" alt="icon3.png" />
请帮助。我正在使用支持 jQuery 的模板。因此,即使是 jQuery 解决方案也可以。
【问题讨论】:
-
APP-A 插件是普通的 php 脚本吗?你不能更新那个?