Fetch filter based on current language

Author Message

Lo' F.

Thursday 04 November 2010 11:58:23 am

Hi guys,

in a fetch tree statement, as the one below, is there a filter I can set to retrieve the current language translated version of the articles only?

{def $items=fetch('content', 'tree', hash('parent_node_id', 2, 'class_filter_type', 'include', 'class_filter_array', array('article')))}

tried ..

{def $language=fetch('content', 'locale')}
{def $items=fetch('content', 'tree', hash('parent_node_id', 2, ..., 'locale_code', $language.locale_code))}

but it doesn't filter the articles based on their language translation...

Please, tip me off! Thx!

loredanaebook.it

Philippe VINCENT-ROYOL

Friday 05 November 2010 1:36:50 am

Hi,

Use 'language' parameters with your current language

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/tree

Cheers

Certified Developer (4.1): http://auth.ez.no/certification/verify/272607
Certified Developer (4.4): http://auth.ez.no/certification/verify/377321

G+ : http://plus.tl/dspe
Twitter : http://twitter.com/dspe

Lo' F.

Sunday 07 November 2010 10:30:39 am

Hi Philippe,

As for what I asked, the following works just great, thank you!

{def $language=fetch('content', 'locale')}
{def $items=fetch('content', 'tree', hash('parent_id_node', 2, ..., 'language', $language.locale_code))}
{foreach $items as $item}
  ...
{/foreach}

...

But I also tumbled to there is a better and easier way to prevent the objects from being displayed if their content isn't translated in the current siteaccess language.

When I ..realized that what I actually need had more to do than just filtering the article's objects, and needed instead to be applied to all the untranslated objects of the entire site, this other solution has made the things more ..easy-peasy (..besides helped me to better understand some site.ini settings' concepts):

On a first step (.. please, feel free to correct me if I miss something or tell something wrong..), for each siteaccess set the locale's language and the objects content's language. In the language list specify the only locale language giving no options if the translation doesn't exsist.

/settings/siteaccess/[fre]/site.ini.append.php

[SiteSettings]
...
SiteURL=localhost/index.php/fre
...

[RegionalSettings]
Locale=fre-FR
ContentObjectLocale=fre-FR
SiteLanguageList[]
SiteLanguageList[]=fre-FR
TextTranslation=enabled

In the admin back-end, then, Content structure tab, select the node, Translations tab, and uncheck "Use the main language if there is no prioritized translation" checkbox.

p.s. If, at first, you get a kernel error (object not found), it might be bacause the template_look.tpl has no other version than the main language.
If this is the case, go to Design tab, look and feel, and make a new translation based on the exsisting one.

loredanaebook.it

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 19:19:06
Script start
Timing: Jan 18 2025 19:19:06
Module start 'layout'
Timing: Jan 18 2025 19:19:06
Module start 'content'
Timing: Jan 18 2025 19:19:06
Module end 'content'
Timing: Jan 18 2025 19:19:06
Script end

Main resources:

Total runtime0.6655 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 589.3203152.6406
Module start 'layout' 0.00650.0030 741.960939.4688
Module start 'content' 0.00940.6546 781.4297557.6172
Module end 'content' 0.66410.0014 1,339.046912.1563
Script end 0.6654  1,351.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.5109160.0002
Check MTime0.00140.2085160.0001
Mysql Total
Database connection0.00140.204110.0014
Mysqli_queries0.599790.1175570.0105
Looping result0.00080.1234550.0000
Template Total0.626194.120.3131
Template load0.00270.404420.0013
Template processing0.623493.676420.3117
Template load and register function0.00010.014910.0001
states
state_id_array0.00220.328510.0022
state_identifier_array0.00120.187120.0006
Override
Cache load0.00240.3539400.0001
Sytem overhead
Fetch class attribute can translate value0.00060.097420.0003
Fetch class attribute name0.00150.230450.0003
XML
Image XML parsing0.00350.526020.0018
class_abstraction
Instantiating content class attribute0.00000.002360.0000
General
dbfile0.00430.6393230.0002
String conversion0.00000.001140.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs