如何将函数的表达式赋值给smarty中的变量

时间:2017-12-04 17:29:08

标签: prestashop smarty

说我有这样的文字:

{l s='Total'}

'l'是一个功能。字符串'Total'实际上是一个翻译:'l'将输出。我需要将生成的翻译分配给另一个智能变量。它有可能吗?如何?

1 个答案:

答案 0 :(得分:2)

您可以使用BEGIN TRY BEGIN TRANSACTION ;with CTE AS ( SELECT [EMP_ID] ,[NAME] ,[DEPT] ,[DATE] ,[Start Time] ,[LOGIN] ,[LATE/AWOL] ,[Team Manager] ,[Senior Manager] ,[SITE] FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=\\VF_RSOSDCNASUDA\xxx\National_Command\National Command Centre\SQL\ESO\ALLAttendance.xlsm;HDR=YES', 'SELECT * FROM [ForEmail$]') ) merge ESO.[dbo].[ALLAttendance$] t using CTE s on s.[EMP_ID] = t.[EMP_ID] and s.[NAME] = t.[NAME] and s.[DEPT] = t.[DEPT] and s.[DATE] = t.[DATE] and s.[Start Time] = t.[Start Time] and s.[LOGIN] = t.[LOGIN] and s.[LATE/AWOL] = t.[LATE/AWOL] and s.[Team Manager] = t.[Team Manager] and s.[Senior Manager] = t.[Senior Manager] and s.[SITE] = t.[SITE] when not matched by target then insert ([EMP_ID],[NAME],[DEPT],[DATE],[Start Time],[LOGIN],[LATE/AWOL],[Team Manager],[Senior Manager],[SITE]) values (s.[EMP_ID],s.[NAME],s.[DEPT],s.[DATE],s.[Start Time],s.[LOGIN],s.[LATE/AWOL],s.[Team Manager],s.[Senior Manager],s.[SITE]); COMMIT END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK END CATCH

执行此操作
assign var

然后在模板文件中的其他位置输出它。

{assign var='translatedString' value={l s='Total'}} 

{$translatedString}

capture

输出
{capture name=translatedString}
    {l s='Total'}
{/capture}

您还可以将捕获分配给var

{$smarty.capture.translatedString}