Forums / Setup & design / Redirect URL after upload

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Redirect URL after upload

Author Message

Felix Laate

Monday 12 September 2005 1:16:15 am

Hi all!

I'm trying to figure out how to control the redirect_url variable of the content/upoload interface from a template.

Basically what I'm doing is letting user upload images. This works well. But I need to control where they come after uploading. As for now, the user gets to /media/images/whatever/upload_image..

Any ideas dear forum?

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Kristof Coomans

Monday 12 September 2005 3:12:01 am

In which template do you want to specify the URI to redirect to?

I don't think content/upload supports this at the moment. But you can modify it to use some HTTP POST variables.

Replace this code:

$upload = new eZContentUpload( );

With the following lines:

$constructorParams = array( );

if ( $http->hasPostVariable( 'RedirectURIAfterResult' ) )
{
    $constructorParams['result_uri'] = $http->postVariable( 'RedirectURIAfterResult' );    
}

if ( $http->hasPostVariable( 'RedirectURIAfterCancel' ) )
{
    $constructorParams['cancel_uri'] = $http->postVariable( 'RedirectURIAfterCancel' );   
}

if ( count( $constructorParams ) > 0 )
{
    $upload = new eZContentUpload( $constructorParams );    
}
else
{
    $upload = new eZContentUpload( );
}

Now you can use the POST variables RedirectURIAfterResult and RedirectURIAfterCancel.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Felix Laate

Monday 12 September 2005 3:27:30 am

Hi Kristof!

Thank you for you swift answer. Really appreciate it. I'll give it a try!

Meanwhile I "solved" the problem by making an override for the folder in which the images are uploaded.

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Kristof Coomans

Monday 12 September 2005 5:05:27 am

I forgot to set the needed session variable, so here's a correction of my code:

$constructorParams = array( );

if ( $http->hasPostVariable( 'RedirectURIAfterResult' ) )
{
    $constructorParams['result_uri'] = $http->postVariable( 'RedirectURIAfterResult' );    
}

if ( $http->hasPostVariable( 'RedirectURIAfterCancel' ) )
{
    $constructorParams['cancel_uri'] = $http->postVariable( 'RedirectURIAfterCancel' );   
}

if ( count( $constructorParams ) > 0 )
{
    $http->setSessionVariable( 'ContentUploadParameters', $constructorParams );
    $upload = new eZContentUpload( $constructorParams );
}
else
{
    $upload = new eZContentUpload( );
}

I've also found a bug in kernel/content/upload.php, which prevents my code snippet to work. See http://ez.no/bugs/view/7139.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Nabil Alimi

Tuesday 13 September 2005 3:56:12 am

Hi,

If you add an Redirect_URI in your form, cant it solve your problem ?

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr