How to redirect from within a module?

Author Message

Heiko Irrgang

Wednesday 16 February 2011 6:40:32 am

Hi, i want to redirect from within a own module to another module.

I have tried the usual way: header(sprintf('Location: %s', $url)); exit();

But ez stops with a message:

"Fatal error: eZ Publish did not finish its request. The execution of eZ Publish was abruptly ended,"

This comes from the exit(), but if i remove the exit, the redirect is ignored.

I found the RedirectOperators which allow redirection from a template and i checked the source: They do exactly the same. Why is it working from a template and not from a module? How can i redirect from a module?

Bertrand Dunogier

Wednesday 16 February 2011 7:28:51 am

In order to provide some feedback about fatal errors, eZ Publish uses a quite classical redirect based mechanism. If you exit() from the code without explaining eZ Publish it is on purpose and that the exit is expected, it will complain like this.

Use this code:

eZExecution::cleanExit();

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Heiko Irrgang

Thursday 17 February 2011 1:33:25 am

Thank you very much

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 18 2025 04:20:02
Script start
Timing: Jan 18 2025 04:20:02
Module start 'layout'
Timing: Jan 18 2025 04:20:02
Module start 'content'
Timing: Jan 18 2025 04:20:03
Module end 'content'
Timing: Jan 18 2025 04:20:03
Script end

Main resources:

Total runtime1.4024 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 587.9375152.6250
Module start 'layout' 0.00500.0030 740.562539.4531
Module start 'content' 0.00811.3929 780.0156533.8203
Module end 'content' 1.40100.0013 1,313.83598.1563
Script end 1.4023  1,321.9922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.2756160.0002
Check MTime0.00160.1166160.0001
Mysql Total
Database connection0.00060.042110.0006
Mysqli_queries1.354496.5830570.0238
Looping result0.00050.0381550.0000
Template Total1.375398.120.6877
Template load0.00200.145220.0010
Template processing1.373397.924820.6866
Template load and register function0.00020.014810.0002
states
state_id_array0.00070.049110.0007
state_identifier_array0.00070.048020.0003
Override
Cache load0.00160.1132170.0001
Sytem overhead
Fetch class attribute can translate value0.00080.055620.0004
Fetch class attribute name0.00110.075040.0003
XML
Image XML parsing0.00070.050420.0004
class_abstraction
Instantiating content class attribute0.00000.000640.0000
General
dbfile0.00090.0608160.0001
String conversion0.00000.000640.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs