繁体   English   中英

Smarty的模板继承和img src属性

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

使用模板继承时,有没有办法使Smarty将srchref属性值转换为正确的URL

例如:

文件:web / tpl / layout.tpl

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

文件:index.tpl

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

文件:dir / index.tpl

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

我认为您应该定义您的基本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