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

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

Jun 13, 2016 pm 01:32 PM
images localhost logo quot smarty

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

1

2

3

4

5

6

7

8

9

10

11

<?php $img_path = dirname(__FILE__)."/images/";

//smarty只要加上assign和display两个方法就行

?>

<img  src="/static/imghw/default1.png" data-src="<?=$img_path?>logo.gif" class="lazy" 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
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Why can't mysql connect to localhost? Why can't mysql connect to localhost? Aug 10, 2023 pm 02:55 PM

The reasons why mysql cannot connect to localhost are that the mysql service is not started, the mysql port is occupied, and there is a problem with the MySQL configuration file. Detailed introduction: 1. In Windows systems, you can open the service manager by entering "services.msc" at the command prompt, then find the mysql service and ensure that its status is "Running". In Linux systems, you can use the "services.msc" command to check and control the service status; 2. You can use the open command and so on.

What should I do if localhost cannot be opened? What should I do if localhost cannot be opened? Nov 07, 2023 pm 02:47 PM

Solution: 1. Check the running status of the server and make sure it is listening on the correct port; 2. Try to temporarily disable the firewall or security software, and then try to access localhost again; 3. Check the hosts file of the operating system to ensure that localhost is resolved correctly ; 4. Try to restart the network adapter or reconfigure the network connection; 5. Try to change the port used by the local server, or close other programs that occupy the same port; 6. Try to manually add the corresponding IP address and domain name in the hosts file, etc.

What does linux localhost mean? What does linux localhost mean? Mar 14, 2023 am 09:53 AM

linux localhost means "computer host name". The host name is used to identify an independent computer on the network; the root in "root@localhost" represents the currently logged-in user. In Linux, the administrator account is root, and the user is root. Log in to the Linux machine as a user.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Foton Motor releases new logo and price information of Xiangling Q series models Foton Motor releases new logo and price information of Xiangling Q series models Sep 12, 2023 pm 09:09 PM

On August 29, Foton Motor held a gorgeous brand refresh conference, bringing a series of exciting news to the industry. The new logo, Auman Zhilan bottom battery replacement products and the new Xiangling Q car became the focus of the press conference. Foton Motor's new logo shows the company's ambitions for the future. Foton Motor said that this new logo symbolizes the renewal and vigorous development of the brand, marking the company's entry into a new stage of development. At the press conference, Foton Motor also launched the much-anticipated Auman Smart Blue bottom battery replacement product to bring users Here comes a more convenient and efficient use experience. At the same time, the newly launched Xiangling Q car series has also attracted a lot of attention. There are 4 models in total, with prices ranging from 167,800 yuan to 168,800 yuan, providing consumers with

HMD Slate Tab 5G leakes as mid-range tablet with Snapdragon 7s Gen 2, 10.6-inch display and Lumia design HMD Slate Tab 5G leakes as mid-range tablet with Snapdragon 7s Gen 2, 10.6-inch display and Lumia design Jun 18, 2024 pm 05:46 PM

With the Skyline, HMD Global is set to unveil a mid-range smartphone in the style of the Nokia Lumia 920 on July 10. According to the latest information from the leaker @smashx_60, the Lumia design will soon also be used for a tablet, which will be c

Photographer submits real photo to AI image contest, bags the 3rd place before telling Photographer submits real photo to AI image contest, bags the 3rd place before telling Jun 16, 2024 pm 06:46 PM

Oneofthecontestsheldby1839Awardsin2024wasspecialinthatsubmissionstoitweretobegeneratedbyartificialintelligenceratherthancreatedwithacamera.ItwasthiscontestthatpiquedthecuriosityofacertainMilesAstray.Insteadofus

What should I do if my iwatch only lights up with the logo but does not turn on? What should I do if my iwatch only lights up with the logo but does not turn on? Mar 25, 2023 pm 02:00 PM

Reasons and solutions for why iwatch only lights up the logo but does not turn on: 1. It is caused by insufficient power and cannot be turned on. You can put the back of the iwatch on the charger; 2. It is caused by system version problems. You can roll the system back to the stable version; 3. , caused by charger or charging cable failure, you can use another iwatch magnetic charging cable and another USB power adapter; 4. caused by hardware failure, it is recommended to go to a professional third-party testing machine for maintenance.

See all articles