This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » How to use the node_view_gui output...
expandshrink

How to use the node_view_gui output into PHP ?

How to use the node_view_gui output into PHP ?

Monday 19 May 2008 2:14:18 pm - 3 replies

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 ?

Monday 19 May 2008 2:57:06 pm

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

Monday 19 May 2008 3:42:39 pm

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 !

Thursday 05 November 2009 10: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

Modified on Thursday 05 November 2009 10:57:25 pm by *- pike

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from