douwei7501 2009-05-14 11:48
浏览 46
已采纳

使用带有gettext的smarty默认变量修饰符

I'm currently using smarty with zend framework, and I have set up smarty to use gettext in the following manner:

{gettext text="resource-identifier"}

This works properly, but I got a problem when trying to use this with the smarty default variable handler. I want to do this:

{$somevar|default:gettext text="resource-identifier"}

But this only prints 'gettext'. Any suggestions to how I can do this. Is it even possible?

  • 写回答

1条回答 默认 最新

  • douwen6274 2009-05-14 13:42
    关注

    For smarty, chaining a result of a function isn't possible like that. You'll need to see if gettext can assign its result to a variable (an assign=varname param), or write your own (and at that point just write a new modifier that is like default_gettext:'resource-id')

    in the assumed assign, it'd look like:

    {gettext text="resource-id" assign="myvar"}
    {$somevar|default:$myvar}
    

    In the new modifier it'd look like:

    {$somevar|default_gettext:"resource-id"}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程