简体   繁体   English

Smarty的模板继承和img src属性

[英]Smarty's template inheritence and img src attribut

Is there a way to make Smarty convert src & href attributs values to the correct URL when using template inheritence 使用模板继承时,有没有办法使Smarty将srchref属性值转换为正确的URL

exmple: 例如:

file: web/tpl/layout.tpl 文件:web / tpl / layout.tpl

<img src="../img/logo.png" />
{block name=content}{/block}

file: index.tpl 文件:index.tpl

{extends file="web/tpl/layout"}
{block name=content} home page content here{/block}

file: dir/index.tpl 文件:dir / index.tpl

{extends file="../web/tpl/layout"}
{block name=content} an other page content here{/block}

I think you should define your base url and use that in your src and href: 我认为您应该定义您的基本URL,并在您的src和href中使用它:

<img src="{$baseurl}/img/logo.png" />
{block name=content}{/block}

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

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