Smarty-3.x模板中图片、CSS、JS的路径怎么替换

WBOY
Release: 2016-06-13 13:32:27
Original
757 people have browsed it

Smarty-3.x模板中图片、CSS、JS的路径如何替换?
比如说index.dwt模板文件里面有句代码:
 Smarty-3.x模板中图片、CSS、JS的路径怎么替换  
也许你会认为这个图片可以显示出来,但是打开http://localhost/index.php,发现图片并未显示,图片的路径变成了http://localhost/images/logo.gif,而真正的路径应该是http://localhost/themes/default/images/logo.gif。还有模板文件里的js、css的路径都需要替换。

Smarty-3.x版本中该如何替换,把替换函数写在哪个位置上?
(Smarty-2.x的版本我知道,只是不知道Smarty-3.x版本的替换)

希望各位大哥帮忙一下!


------解决方案--------------------
Smarty-3.x 也还有这种问题么?
------解决方案--------------------
将路径赋给变量,src中直接写变量+文件名:

PHP code

<?php $img_path = dirname(__FILE__)."/images/";
//smarty只要加上assign和display两个方法就行
?>
<img  src="<?=%24img_path?>logo.gif" border="0" alt=" Smarty-3.x模板中图片、CSS、JS的路径怎么替换 " >
<br><font color="#e78608">------解决方案--------------------</font><br>定一个basepath常量,根据需要改
<br><font color="#e78608">------解决方案--------------------</font><br>楼主该睡了 <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!