How to send module result back to the form page ?

Author Message

Franck Grenier

Thursday 17 December 2009 1:04:25 am

Hello,
I've created a quizz extension with a module that handles the user answer.
The quizz form is submitted to my module at "quizz/reponse". After the module actions, I would like to go back to the quizz page with the result of the module.
How can I do that ?

Developer at Open Wide

Jérôme Vieilledent

Monday 21 December 2009 2:51:59 am

Hi Franck

First, you may use eZ Survey extension for that ;).

eZ Publish sets a LastAccessesURI session variable. Then, what you to do is to check if it exists and redirect the user to this URI or to a default one.

Example :

$Module = $Params['Module'];
$http = eZHTTPTool::instance();

if ( $http->hasSessionVariable( "LastAccessesURI" ) ) // Check if LastAccessesURI exists
  $userRedirectURI = $http->sessionVariable( "LastAccessesURI" );
else
  $userRedirectURI = 'content/view/full/2'; // Default redirect

$Module->redirectTo( $userRedirectURI );

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 21:46:46
Script start
Timing: Jan 30 2025 21:46:46
Module start 'layout'
Timing: Jan 30 2025 21:46:46
Module start 'content'
Timing: Jan 30 2025 21:46:46
Module end 'content'
Timing: Jan 30 2025 21:46:46
Script end

Main resources:

Total runtime0.0233 sec
Peak memory usage8,192.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.2656151.2266
Module start 'layout' 0.00530.0037 739.4922220.7188
Module start 'content' 0.00900.0127 960.2109998.4609
Module end 'content' 0.02160.0016 1,958.671929.9922
Script end 0.0233  1,988.6641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002912.2524140.0002
Check MTime0.00114.8965140.0001
Mysql Total
Database connection0.00083.235010.0008
Mysqli_queries0.00229.454330.0007
Looping result0.00000.064510.0000
Template Total0.00125.110.0012
Template load0.00093.896910.0009
Template processing0.00031.180610.0003
Override
Cache load0.00062.617010.0006
General
dbfile0.00114.548680.0001
String conversion0.00000.037940.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