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"}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?