Smarty - 包含模板并更新现有变量 [英] Smarty - include template and update an existing variable
本文介绍了Smarty - 包含模板并更新现有变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近开始与Smarty合作,我试图找到解决方法。以下是我目前不知道的内容:
I've recently started working with Smarty and I'm trying to find my way around. Here's what I don't know in the very moment:
我包含一个文件:
{include file="nforum/_partials/box_forum.tpl"}
在那个文件中,我有这个:
In that file, I have this:
<a href="{$t->link}">{$t->title|truncate:$link_truncate}</a>
我想在传递$ link_truncate的值时包含模板(不在box_forum中)。 tpl - 这对我很重要!)
I would like to pass $link_truncate a value of 30 while including the template (not inside the box_forum.tpl - that's important to me!)
我在尝试:
I'm trying with:
{include file="nforum/_partials/box_forum.tpl" $link_truncate = 30}
没有成功。
推荐答案
在包含模板之前声明:
{assign var="link_truncate" value="30"}
这篇关于Smarty - 包含模板并更新现有变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文