Perform Function then Redirect

Author Message

Lando C

Tuesday 03 February 2009 3:36:37 pm

I'm working in ez 4 and am running into an issue regarding the $Result['path']

Haven't been able to find a solution elsewhere on the forums, so hopefully someone can help me out here or at least point me in the direction of where to look.

I'm working with a custom extension that I created for use in our back office.
There is a link I want to create that simply removes a result from a specified DB table by calling a basic function.

In order for the function to execute properly, there are ID params that I'm passing through the URL.

HOWEVER, once the function completes, I want there to be a redirect behind the scenes back to where the user came from.

From what I was able to deduct the best method for this is with something like:

myFunction(id1,id2)

$tpl =& templateInit();
$Result = array();					
$Result['content'] = $tpl->fetch( "design:myTemplate.tpl" );
$Result['path'] = array(array('url' => '/home/original_URL/', 'text' => 'Origin'));

As I mentioned, my custom function executes perfectly, then it runs through the above code...and the URL is never redirected.

I DO see the template appearance that I'm calling $Result['content']...but the URL is not changing.

What am I doing wrong? Missing something? Is it something I needed to do upon creation of the extension in the first place? Am I way off and there is an even easier method in ez 4.0?

:) Thanks for any help in advance!

Gaetano Giunta

Wednesday 04 February 2009 1:01:49 am

In fact the $Result['path'] you are setting up is not used for redirecting to other urls, it is only used for displaying a navigation bar in the templates.

You might want to take a look at how kernel/layout/set.php does it, if you want to handle the redirect internally within eZ (ie. without an http redirect).

Or use $Module->redirectTo()

Principal Consultant International Business
Member of the Community Project Board

Lando C

Wednesday 04 February 2009 6:26:27 am

Perfect, thanks so much for the followup Gaetano and the multiple solutions :)

Always a plus!

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 22:24:31
Script start
Timing: Jan 18 2025 22:24:31
Module start 'layout'
Timing: Jan 18 2025 22:24:31
Module start 'content'
Timing: Jan 18 2025 22:24:31
Module end 'content'
Timing: Jan 18 2025 22:24:31
Script end

Main resources:

Total runtime0.0206 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9141152.6250
Module start 'layout' 0.00740.0032 740.539139.4453
Module start 'content' 0.01060.0074 779.984489.4453
Module end 'content' 0.01800.0025 869.429734.3047
Script end 0.0205  903.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002713.1166140.0002
Check MTime0.00115.3506140.0001
Mysql Total
Database connection0.00157.398510.0015
Mysqli_queries0.003517.131330.0012
Looping result0.00000.077710.0000
Template Total0.00209.510.0020
Template load0.00125.793510.0012
Template processing0.00083.692310.0008
Override
Cache load0.00094.158510.0009
General
dbfile0.00021.160880.0000
String conversion0.00000.038340.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