Forums / Developer / Perform Function then Redirect

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!