Forums / Developer / How to use the node_view_gui output into PHP ?

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.

eZ debug

Timing: Jan 18 2025 03:08:02
Script start
Timing: Jan 18 2025 03:08:02
Module start 'content'
Timing: Jan 18 2025 03:08:03
Module end 'content'
Timing: Jan 18 2025 03:08:03
Script end

Main resources:

Total runtime1.2186 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 588.9609180.8125
Module start 'content' 0.00711.0923 769.7734598.3438
Module end 'content' 1.09940.1192 1,368.1172337.3672
Script end 1.2186  1,705.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.3112210.0002
Check MTime0.00150.1205210.0001
Mysql Total
Database connection0.00060.051010.0006
Mysqli_queries1.146494.07691990.0058
Looping result0.00190.15621970.0000
Template Total1.190397.720.5952
Template load0.00210.171120.0010
Template processing1.188297.506320.5941
Template load and register function0.00010.006610.0001
states
state_id_array0.00100.080010.0010
state_identifier_array0.00080.063320.0004
Override
Cache load0.00170.1389300.0001
Sytem overhead
Fetch class attribute can translate value0.00120.099440.0003
Fetch class attribute name0.00180.147060.0003
XML
Image XML parsing0.00130.103640.0003
class_abstraction
Instantiating content class attribute0.00000.000970.0000
General
dbfile0.00450.3707330.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs