Smarty - include template and update an existing variable

有些话、适合烂在心里 提交于 2019-12-13 08:20:04

问题


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:

I'm including a file:

{include file="nforum/_partials/box_forum.tpl"}

In that file, I have this:

<a href="{$t->link}">{$t->title|truncate:$link_truncate}</a>

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}

without success. How can I do it?


回答1:


declare, before include the template:

{assign var="link_truncate" value="30"}


来源:https://stackoverflow.com/questions/26753563/smarty-include-template-and-update-an-existing-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!