Forums / Developer / A way to get module_result ALONE

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