Share » Forums » Developer » i18n on attribute_view_gui output

i18n on attribute_view_gui output

i18n on attribute_view_gui output

Monday 21 February 2011 5:14:54 am - 4 replies

Modified on Monday 21 February 2011 5:17:02 am by Christopher Grondahl

Author Message

Marko Žmak

Monday 21 February 2011 5:32:29 am

You can store the content of attribute_view_gui using set-block:

{def $output=''}
{set-block variable='output'}
{attribute_view_gui attribute=$node.data_map.productlanguage}
{/set-block}

and then use i18n with the $output variable.

Also note, that if you're using this with an attribute of type XML Field, you'll get the output HTML tags in the $output variable, so it could cause you some headache if you use i18n on it.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Christopher Grondahl

Monday 21 February 2011 10:02:55 am

Excellent! Works like a charm with a little trimming (for some reason, the $output had a lot of space before and after). Finished code:

{def $output=''}
{set-block variable='output'}
    {attribute_view_gui attribute=$node.data_map.productlanguage}
{/set-block}
{def $trimoutput=$output|trim()}
                    
{$trimoutput|i18n('core/shop')}

Chris

ez site: http://www.acem.no

Every day is Groundhog Day

Marko Žmak

Tuesday 22 February 2011 12:02:25 am

The reason why the $output has a lot of spaces is because there's a lot of spaces in your code. All the content that is inside the {set-block} gets in the $output variable, including all the whitespaces in it.

But yes, trim() is the sollution. You can do it even in a more compact way:

{$output|trim()|i18n('core/shop')}

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Christopher Grondahl

Wednesday 23 February 2011 3:07:56 pm

Great - even better - thanks a lot!

finished code:

{def $output=''}
{set-block variable='output'}
    {attribute_view_gui attribute=$node.data_map.productlanguage}
{/set-block}
                    
{$output|trim()|i18n('core/shop')

Chris

ez site: http://www.acem.no

Every day is Groundhog Day

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu