Maxime Thomas
|
Thursday 29 May 2008 10:57:20 pm
You may use your custom library (e.g. if you would like to you scriptacoulus, extjs or jQuery) and access your custom eZPublish templates via the "layout/set" functionnality. So, you design your own functionnality in a custom module, like fetching meteo on yahoo.com, and to call it, you may use this one to change the layout : http://www.mydomain.com/mysiteacess/layout/set/ajax/mymodule/myfunction/parameters.. All you have to do is to declare a new pagelayout template for ajax (pagelayout_ajaxa.tpl), set up your layout.ini file and finally edit the pagelayout file as :
{$module_result.content}
Or maybe there's something eZier but I haven't found.
Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou
Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas
|
Patrick Renaud
|
Thursday 24 July 2008 6:09:01 am
Hi everybody, I'm trying to use Ajax to load some templates. Kristof's answer was very promising, but I couldn't make it work ( see http://ez.no/developer/forum/setup_design/how_to_ez_ajax_my_site/re_how_to_ez_ajax_my_site ), so that I tried Maxime's.
It works, or almost...
The template I need to fetch displays a different information according to the current user. The problem is, when you call this template using ajax, the user is always the anonymous one. Does anybody have an idea on how to solve this ?
Ca, c'est fait !
|
Paul Wilson
|
Thursday 24 July 2008 5:05:23 pm
Hi Patrick, Here's a cut-down version of where I got to. I did get it to work. Please note that for simplicity I have stripped out some of the logic in this code (some elements to check permissions), so there may be some extra pieces here that can be safely removed / ignored. Some of the include statements are in peculiar places through the code for similar reasons. I'm heading away for a few days, so apologies for the rushed code & reply. hth - Paul
function EditBox($ContentObjID){
// Add Includes required for function, others loaded IFF logic shows they're needed.
include_once( 'kernel/classes/ezcontentobject.php' );
include_once( 'kernel/classes/ezcontentclass.php' );
include_once( 'kernel/classes/ezcontentobjectattribute.php' );
include_once( 'kernel/classes/ezcontentobjectversion.php' );
include_once( 'kernel/classes/ezcontentfunctions.php' );
include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
$obj = $ContentObjID ? eZContentObject::fetch( $ContentObjID ) : false;
$classID = $obj->attribute( 'contentclass_id' );
$class = eZContentClass::fetch( $classID );
$EditLanguage="eng-AU";
$FromLanguage="eng-AU";
$ContentObjectLanguageCode=="eng-AU";
$CurrentVersion = $obj->attribute('current_version');
// Set the new version as the published version
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $obj->attribute( 'id' ), 'version' => $version->attribute( 'version' ) ) );
$CurrentVersion = $obj->attribute('current_version');
require_once( 'kernel/common/template.php' );
$tpl = templateInit();
$res = eZTemplateDesignResource::instance();
$res->setKeys( array( array( 'object', $obj->attribute( 'id' ) ),
array( 'class', $class->attribute( 'id' ) ),
array( 'class_identifier', $class->attribute( 'identifier' ) ),
array( 'class_group', $class->attribute( 'match_ingroup_id_list' ) ) ) );
$originalContentAttributes =& $obj->contentObjectAttributes();
$tpl->setVariable( 'view_parameters', $viewParameters );
$tpl->setVariable( 'edit_language', $EditLanguage );
$tpl->setVariable( 'from_language', $FromLanguage );
$tpl->setVariable( 'object', $obj );
$tpl->setVariable( 'class', $class );
$tpl->setVariable( 'current_version', $CurrentVersion );
$tpl->setVariableRef( 'content_attributes', $originalContentAttributes );
$Result = array();
$Result['content'] = $tpl->fetch( 'design:content/edit.tpl' );
// Create New Object Response
$objResponse = new xajaxResponse();
$returnthismessage=$Result['content'];
$objResponse->setReturnValue($returnthismessage);
// Send Response
return $objResponse;
|
Maxime Thomas
|
Monday 04 August 2008 10:37:03 pm
I'm not sure to understand what you have said, just after some weeks of holidays...
When you enter the module mecanism, you have to deal with the pagelayout template. So, I suppose you have to disable the pagelayout in the Result variable to do this way.
Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou
Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas
|