[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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 = "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 at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Alan.Stiles
Sent: Tuesday, 10 May 2016 11:57 PM
To: eprints-tech at 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<http://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 )

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20160510/f23cb419/attachment-0001.html