EPrints Technical Mailing List Archive

Message: #05685


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] [solved] redirecting to external URLs


Okay, so I think I’ve resolved it and I wasn’t too far off originally…

 

Rather than messing with the redirect_to_me_url () function, the answer (from examining https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/ScreenProcessor.pm#L313) appears to be to just set the desired destination as redirect in the screen processor hash.

 

e.g.      $self->{processor}->{redirect} = “http://wiki.eprints.org”;

 

Alan

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Alan.Stiles
Sent: 11 May 2016 09:17
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] redirecting to external URLs

 

Thanks Matt, but it’s the latter I’m after – sending the user automatically to a new location with parameters  based upon the values submitted in a form.

 

Alan

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Matthew Brady
Sent: 10 May 2016 23:49
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] redirecting to external URLs

 

Hi Alan,

 

Do you want the user to click on a link ? Or force the page to redirect to the new location automatically??

 

If it’s the former, you could do it in a similar way that the DOI’s get processed…

 

e.g. in the eprint_fields.pl

{

        name => 'id_number',

        type => 'text',

        render_value => 'EPrints::Extras::render_possible_doi',

},

 

Then in perl_lib/EPrints/extras.pm

 

 

sub render_possible_doi

{

        my( $session, $field, $value ) = @_;

 

        $value = "" unless defined $value;

 

        if( $value !~ /^(doi:)?10\.\d\d\d\d\// ) { return $session->make_text( $value ); }

       

        $value =~ s/^doi://;

 

        my $url = "" href="http://dx.doi.org/$value">http://dx.doi.org/$value";

        my $link = $session->render_link( $url );

        $link->appendChild( $session->make_text( $value ) );

        return $link;

}

 

This will take the value entered into the id_number field, and render it as a link on the screen, prefixing it with the appropriate http url leader etc…

 

 

Cheers

 

Matt

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Alan.Stiles
Sent: Tuesday, 10 May 2016 11:57 PM
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] redirecting to external URLs

 

So anyone know how I should be redirecting the user to an alternative URL based on some processing in a Screen action?

 

As it is, I’m setting the url in the action by

 

$self->{processor}->{redirect_to_url} = “http://example.org”;

 

and then checking for it in

 

sub redirect_to_me_url {

                …

                return $self->{processor}->{redirect_to_url};

}  

 

It seems a little too hacky!

Cheers,

 

 

Alan Stiles

Digital Repository Developer

Library Services, The Open University

oro.open.ac.uk

 

-- The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302). The Open University is authorised and regulated by the Financial Conduct Authority.

 
_____________________________________________________________
This email (including any attached files) is confidential and is for the intended recipient(s) only. If you received this email by mistake, please, as a courtesy, tell the sender, then delete this email.
 
The views and opinions are the originator's and do not necessarily reflect those of the University of Southern Queensland. Although all reasonable precautions were taken to ensure that this email contained no viruses at the time it was sent we accept no liability for any losses arising from its receipt.
 
The University of Southern Queensland is a registered provider of education with the Australian Government.
(CRICOS Institution Code QLD 00244B / NSW 02225M, TEQSA PRV12081 )