i18n on attribute_view_gui output

Author Message

Christopher Grondahl

Monday 21 February 2011 5:14:54 am

I want to put a i18n on the output of this - any suggestions?

{attribute_view_gui attribute=$node.data_map.productlanguage}

Chris

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

Every day is Groundhog Day

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:17:54
Script start
Timing: Jan 18 2025 02:17:54
Module start 'layout'
Timing: Jan 18 2025 02:17:54
Module start 'content'
Timing: Jan 18 2025 02:17:56
Module end 'content'
Timing: Jan 18 2025 02:17:56
Script end

Main resources:

Total runtime1.1460 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0042 587.9219152.6250
Module start 'layout' 0.00420.0029 740.546939.4688
Module start 'content' 0.00711.1369 780.0156570.0000
Module end 'content' 1.14400.0019 1,350.015616.1563
Script end 1.1459  1,366.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2679160.0002
Check MTime0.00140.1183160.0001
Mysql Total
Database connection0.00040.036710.0004
Mysqli_queries1.083694.5535630.0172
Looping result0.00070.0626610.0000
Template Total1.119997.720.5600
Template load0.00180.157320.0009
Template processing1.118197.563620.5590
Template load and register function0.00010.012010.0001
states
state_id_array0.00070.057310.0007
state_identifier_array0.00160.142720.0008
Override
Cache load0.00150.1315260.0001
Sytem overhead
Fetch class attribute can translate value0.00060.053120.0003
Fetch class attribute name0.00250.215670.0004
XML
Image XML parsing0.00300.261920.0015
class_abstraction
Instantiating content class attribute0.00000.0021100.0000
General
dbfile0.00330.2892240.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs