How to get 'url' of an object in chosen language version.

Author Message

Pawel Graczyk

Tuesday 06 October 2009 2:54:23 am

How to get 'url' of an object in some language version?

I have a 'survey' object and I know its id, so I can fetch it from node in this way:


$surveyObject = eZContentObjectTreeNode::fetchByContentObjectID($this->userAndGroupData['survey_id']);

then:

$url = $surveyObject[0]->attribute('url');

It gives me url in last version (if I'am correct...).

Thing is I need my 'url' parameter for other object language version. How to get this version.
having object id and language identifier?

I would like to do it in clean php, without using templates.

Piotrek Karaƛ

Wednesday 07 October 2009 12:55:07 am

I'll extend this question with another example. Node $node has two translations with two different object names that should result in two different URL aliases. URL translations are enabled (version 4.2, default config):

<?php
$node = eZContentObjectTreeNode::fetch( 67, 'pol-PL' ); //default lang
var_dump( $node->urlAlias() );
$node = eZContentObjectTreeNode::fetch( 67, 'eng-US' );
var_dump( $node->urlAlias() );
?>

The above code returns two differently populated $node objects, but the urlAlias() method returns the same value - why? Is it because it always returns a valid URL alias based on environment (current siteaccess) settings?

Since not the above, what would be the way to fetch URL aliases for different translations of a node?

Thanks,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

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

Main resources:

Total runtime0.6791 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.1563152.6563
Module start 'layout' 0.00570.0023 740.812539.5078
Module start 'content' 0.00800.6695 780.3203528.1094
Module end 'content' 0.67750.0016 1,308.42978.4219
Script end 0.6790  1,316.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4931160.0002
Check MTime0.00140.2021160.0001
Mysql Total
Database connection0.00060.093610.0006
Mysqli_queries0.627692.4222540.0116
Looping result0.00070.1104520.0000
Template Total0.644294.920.3221
Template load0.00240.353920.0012
Template processing0.641894.512920.3209
Template load and register function0.00020.023710.0002
states
state_id_array0.00130.186010.0013
state_identifier_array0.00210.311020.0011
Override
Cache load0.00190.2805200.0001
Sytem overhead
Fetch class attribute can translate value0.00100.146020.0005
Fetch class attribute name0.00150.218830.0005
XML
Image XML parsing0.00080.122920.0004
class_abstraction
Instantiating content class attribute0.00000.001330.0000
General
dbfile0.00200.2979170.0001
String conversion0.00000.004940.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs