Thursday 18 October 2007 7:18:41 am
Hi Chris, I solved the problem by writing a template operator:
class myOperators
{
/*!
Constructor
*/
function myOperators()
{
$this->Operators = array('bg_include_text' );
}
function &operatorList()
{
return $this->Operators;
}
function namedParameterPerOperator()
{
return true;
}
function namedParameterList()
{
return array( 'bg_include_text' => array( 'id' => array( 'type' => 'string',
'required' => true,
'default' => '' )
);
}
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace,
&$currentNamespace, &$operatorValue, &$namedParameters )
{
switch ( $operatorName )
{
case 'bg_include_text':
{
$operatorValue = $this->bg_include_text( $namedParameters['id']
);
} break;
}
}
function bg_include_text( $id )
{
/* tries to fetch a text that has been put in common_ini_settings under that name */
$classID = eZContentObjectTreeNode::classIDByIdentifier( 'common_ini_settings' );
$chosenNodeList = eZContentObject::fetchFilteredList( array( 'contentclass_id' => $classID ), 0, 1 );
$chosenNode = $chosenNodeList[0];
$dataMap = $chosenNode->dataMap();
$key="".$id.""; // string conversion
$operatorValue= $dataMap[$key]->content();
return $operatorValue;
}
/// privatesection
var $Operators;
}
?>
In the admin interface, I add attributes (of type text-line) to the class definition of COMMON INI SETTINGS, and then, the user can edit the common ini settings and fill them with whatever text. for example, I created an attribute tac_url which is the URL of the terms and conditions... the template uses then {let tac_url = bg_include_text(tac_url)} to retrieve the URL into the variable.
{let tac_url = bg_include_text(tac_url)}
Let me know if this is clear enough or if you need more details! Cheers, </Pascal>
|