A way to get module_result ALONE

Author Message

Gabriel Ambuehl

Wednesday 07 December 2005 7:48:40 am

Is there any way (aside of using a page layout that has only {module_result} in it which is problematical as the same layout will be used in every link ) to fetch ONLY the module_result, e.g. the full view of a content object.

I want to fetch content object views for AJAX and I only need the content, not all the pagelayout it's usually wrapped in...

Visit http://triligon.org

Paul Forsyth

Wednesday 07 December 2005 7:55:03 am

If you are in PHP could you not just use:

$tpl =& templateInit();
$tpl->fetch(<your tpl>);

to get just the template result? Or maybe make a small function to do this for you?

Clemens T

Wednesday 07 December 2005 8:28:52 am

Do something like this:

$Result = array();
$Result['content'] = & $tpl->fetch( 'design:myModule/myview.tpl' );
$Result['path'] = array( array( 'url' => 'myModule/myView/',
                                'text' => 'my View') );
$Result['pagelayout'] = false;

Hopefully this will help you.
Greets,
Clemens

Gabriel Ambuehl

Friday 09 December 2005 2:38:06 am

This is how I finally did it (to fetch the full view of a content node):

<?php
include_once( 'kernel/classes/ezcontentobject.php' );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/common/template.php' );
include_once( 'lib/ezutils/classes/ezexecution.php' );

$nodeID = false;
$http =& eZHTTPTool::instance();
$module =& $Params["Module"];
$originalParameters=$module->OriginalUnorderedParameters;



if (array_key_exists('nodeID', $originalParameters) ) {
    $nodeID = $originalParameters['nodeID'];
}

if ( !( $nodeID) ) {
    eZDebug::writeError( "nodeid not set as param");
    return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
}



$node =& eZContentObjectTreeNode::fetch( $nodeID);
if ( is_object( $node ) )
        {

            
            
            
            $tpl =& templateInit();
            $tpl->setVariable( 'node', $node);
            $tpl->setVariable( 'nodeid', $nodeID );
            
            
            echo ($tpl->fetch( "design:resultonly.tpl" ));
            eZExecution::cleanExit();
        }
else {
    return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
}

?>

whereas resultonly.tpl simply contains an appropriate node_view_gui call.

But thanks for your inputs ;)

Visit http://triligon.org

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 19 2025 04:24:08
Script start
Timing: Jan 19 2025 04:24:08
Module start 'layout'
Timing: Jan 19 2025 04:24:08
Module start 'content'
Timing: Jan 19 2025 04:24:09
Module end 'content'
Timing: Jan 19 2025 04:24:09
Script end

Main resources:

Total runtime0.8990 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 590.2813152.6250
Module start 'layout' 0.00540.0024 742.906339.4453
Module start 'content' 0.00780.8896 782.3516547.1953
Module end 'content' 0.89740.0015 1,329.546912.4688
Script end 0.8990  1,342.0156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4010160.0002
Check MTime0.00150.1711160.0001
Mysql Total
Database connection0.00080.086110.0008
Mysqli_queries0.850494.5927620.0137
Looping result0.00060.0660600.0000
Template Total0.870996.920.4355
Template load0.00330.372420.0017
Template processing0.867596.497720.4338
Template load and register function0.00020.019310.0002
states
state_id_array0.00100.111010.0010
state_identifier_array0.00090.101020.0005
Override
Cache load0.00270.2976200.0001
Sytem overhead
Fetch class attribute can translate value0.00170.193130.0006
Fetch class attribute name0.00100.109940.0002
XML
Image XML parsing0.00040.047230.0001
class_abstraction
Instantiating content class attribute0.00000.001140.0000
General
dbfile0.00070.0809100.0001
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
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
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs