Forums / Developer / How to get 'url' of an object in chosen language version.
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