Friday 17 November 2006 11:53:34 am
Hi Atle This is actually a good question - I could not find a way to fetch a node in a specific language. Most likely you can somehow access the translations from the node object but I did not see a good way to do this, maybe someone else can help you there.
Here my ideas how to solve the problem: Depending on what exactly you want, you could fetch the content attributes for the object that is encapsulated by the current node:
{def $attributes = fetch( 'content', 'contentobject_attributes',
hash( 'version', $node.object.current ,
'language_code', 'fre-FR') )}
{foreach $attributes as $attribute}
{$attribute.content} <br />
{/foreach}
Alternatively you could write your own template operator, like this:
<?php
include_once('kernel/classes/ezcontentobjecttreenode.php');
class MyEZFunctions
{
var $Operators;
function MyEZFunctions()
{
$this->Operators = array('my_fetch_node_translation');
}
function &operatorList()
{
return $this->Operators;
}
function namedParameterPerOperator()
{
return true;
}
function namedParameterList()
{
return array('my_fetch_node_translation' => array('node_id' => array('type' => 'integer',
'required' => true,
'default' => '' ),
'language_code' => array('type' => 'string',
'required' => false,
'default' => false )));
}
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace,
&$currentNamespace, &$operatorValue, &$namedParameters )
{
switch ( $operatorName )
{
case 'my_fetch_node_translation':
$operatorValue =& eZContentObjectTreeNode::fetch($namedParameters['node_id'],
$namedParameters['language_code']);
break;
}
}
}
?>
Please note that the above code is an excerpt from one of my template operator classes, so there might some copy and paste errors. If you should find a native EZ function that does this, please post it here. Have a nice weekend Claudia
|