views:

954

answers:

1

Hi there.

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?

A: 

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"}
Justin
Hmm, ok. I think I'm going to assign a variable in the top of the view-file with the default text, as it is usually the same through the whole page. I was thinking about doing the same, only setting the variable in the controller, but assigning a variable in smarty is a better approach. It keeps up the separation between controller and view better.
Erik