How to use the node_view_gui output into PHP ?

Author Message

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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 19:38:40
Script start
Timing: Jan 30 2025 19:38:40
Module start 'layout'
Timing: Jan 30 2025 19:38:40
Module start 'content'
Timing: Jan 30 2025 19:38:40
Module end 'content'
Timing: Jan 30 2025 19:38:40
Script end

Main resources:

Total runtime0.0239 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.2656151.2266
Module start 'layout' 0.00630.0038 739.4922220.7188
Module start 'content' 0.01010.0122 960.21091,001.8672
Module end 'content' 0.02230.0015 1,962.078137.9922
Script end 0.0239  2,000.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002811.6933140.0002
Check MTime0.00114.6145140.0001
Mysql Total
Database connection0.00062.657510.0006
Mysqli_queries0.004117.051130.0014
Looping result0.00000.032910.0000
Template Total0.00114.710.0011
Template load0.00093.706810.0009
Template processing0.00021.011410.0002
Override
Cache load0.00062.569810.0006
General
dbfile0.00145.938880.0002
String conversion0.00000.028940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs