Sébastien Antoniotti
|
Monday 19 May 2008 5:14:18 am
Hi, I'm trying to get the XHTML output of the node_view_gui function into PHP. By example, to get the XHTML render of content/view/line/50 (without the pagelayout of course), I tried this :
$myNode = eZContentObject::fetchByNodeID(50, $asObject = true);
include_once( "kernel/common/template.php" );
$tpl = templateInit();
$tpl->setVariable( 'node', $myNode );
$xhtmlContent = $tpl->fetch( 'design:templates/classes/car/line.tpl' );
echo $xhtmlContent;
But that doesn't works... Is this possible to do that ?
eZ Publish Freelance
web : http://www.webaxis.fr
|
Felix Laate
|
Monday 19 May 2008 5:57:06 am
Hi Sébastien, having a look at kernel/content/view.php:
$localVars = array( "cacheFileArray", "NodeID", "Module", "tpl",
"LanguageCode", "ViewMode", "Offset", "ini",
"cacheFileArray", "viewParameters", "collectionAttributes",
"validation" );
...
$cacheFileArray = array( 'cache_dir' => false, 'cache_path' => false );
$args = compact( $localVars );
$data = eZNodeviewfunctions::contentViewGenerate( false, $args ); // the false parameter will disable generation of the 'binarydata' entry
return $data['content']; // Return the $Result array
Maybe the function <i>eZNodeviewfunctions::contentViewGenerate</i> does the trick? Felix
Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com
|
Sébastien Antoniotti
|
Monday 19 May 2008 6:42:39 am
Hi Felix, You're right ! It's OK, this is the code I used to get the XHTML output of content/view/line/589 :
$cacheFileArray = array( 'cache_dir' => false, 'cache_path' => false );
$NodeID = 589;
$Module = $Params['Module'];
$tpl = templateInit();
$LanguageCode = $Params['Language'];
$ViewMode = "line";
$Offset = $Params['Offset'];
$ini = eZINI::instance();
$Year = $Params['Year'];
$Month = $Params['Month'];
$Day = $Params['Day'];
$viewParameters = array( 'offset' => $Offset,
'year' => $Year,
'month' => $Month,
'day' => $Day,
'namefilter' => false );
$viewParameters = array_merge( $viewParameters, $UserParameters );
$collectionAttributes = false;
if ( isset( $Params['CollectionAttributes'] ) )
$collectionAttributes = $Params['CollectionAttributes'];
$validation = array( 'processed' => false,
'attributes' => array() );
if ( isset( $Params['AttributeValidation'] ) )
$validation = $Params['AttributeValidation'];
$localVars = array( "cacheFileArray", "NodeID", "Module", "tpl",
"LanguageCode", "ViewMode", "Offset", "ini",
"cacheFileArray", "viewParameters", "collectionAttributes",
"validation" );
$args = compact( $localVars );
$data = eZNodeviewfunctions::contentViewGenerate( false, $args ); // the false parameter will disable generation of the 'binarydata' entry
$xhtmlContent = $data['content'];
return $xhtmlContent['content'];
Thanks a lot !
eZ Publish Freelance
web : http://www.webaxis.fr
|
*- pike
|
Thursday 05 November 2009 1:53:47 pm
Hi I would have liked to paste some usefull code here, but its not working. I gave up and removed my code. Sorry. $0c, *-pike
---------------
The class eZContentObjectTreeNode does.
|