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

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 19 2025 03:21:54
Script start
Timing: Jan 19 2025 03:21:54
Module start 'layout'
Timing: Jan 19 2025 03:21:54
Module start 'content'
Timing: Jan 19 2025 03:21:56
Module end 'content'
Timing: Jan 19 2025 03:21:56
Script end

Main resources:

Total runtime1.2020 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.1563152.6250
Module start 'layout' 0.00660.0026 741.781339.4453
Module start 'content' 0.00921.1913 781.2266612.2891
Module end 'content' 1.20050.0015 1,393.515616.1641
Script end 1.2019  1,409.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.3167160.0002
Check MTime0.00160.1295160.0001
Mysql Total
Database connection0.00190.156110.0019
Mysqli_queries1.133894.3263650.0174
Looping result0.00060.0509630.0000
Template Total1.161496.620.5807
Template load0.00220.185720.0011
Template processing1.159296.439320.5796
Template load and register function0.00010.010210.0001
states
state_id_array0.00140.114610.0014
state_identifier_array0.00110.090820.0005
Override
Cache load0.00190.1584330.0001
Sytem overhead
Fetch class attribute can translate value0.00080.064530.0003
Fetch class attribute name0.00090.076380.0001
XML
Image XML parsing0.00160.129030.0005
class_abstraction
Instantiating content class attribute0.00000.0014100.0000
General
dbfile0.00120.0987280.0000
String conversion0.00000.000740.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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/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: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs