Gossamer Forum
Home : Gossamer Threads Inc. : Discussion :

GT::CGI::redirect from within a template

Quote Reply
GT::CGI::redirect from within a template
Is it possible to call <%GT::CGI::redirect($someurl)%> from within a template? I'm having trouble getting that to work... Is it because it's too late to send HTTP headers at the top of a template file? Any suggestions would be appreciated.

Thanks.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] GT::CGI::redirect from within a template In reply to
Hi,

I would think so. The template parser is called after a print $IN->header or is out put after one.

In order to redirect, you'd need to make a script that handles that case, and doesn't print out those headers. Not sure which program you are using this in, so I can't give you any clues.

But if you know the script that is printing out your request, you can edit that script to not send standard headers. _Old_ versions of jump.cgi in Links used to show this pretty well.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] GT::CGI::redirect from within a template In reply to
Thanks, pugdog. Actually it's DbMan SQL, so there's the one db.cgi script that handles the entire front end of things. I'll do a little poking around to see where it prints headers and maybe hack something there.

Is my syntax basically correct for using GT::CGI? Would that work if called prior to any HTTP headers being printed?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] GT::CGI::redirect from within a template In reply to
Quote:
Is my syntax basically correct for using GT::CGI? Would that work if called prior to any HTTP headers being printed?

It should work in LinksSQL (format wise), so I would say yes.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [hennagaijin] GT::CGI::redirect from within a template In reply to
Hi,

Like andy said, it should work, if you can "kill" the extra print headers command. Might take some trial and error to make work, or it might not work.

I don't have a copy of dbman to even suggest where/what to do.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [hennagaijin] GT::CGI::redirect from within a template In reply to
Hi hennagaijin,

why not just use meta tags:

meta http-equiv="refresh" content="0; URL=/cgi-bin/script.cgi"

Regards

Niko
Quote Reply
Re: [el noe] GT::CGI::redirect from within a template In reply to
Yes, meta redirect tags are an option. The problem is that they're not as secure or reliable as doing the redirect server-side. But I suppose it's fine as a backup plan.

Thanks to all for the advice.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] GT::CGI::redirect from within a template In reply to
Quote:
Is it possible to call <%GT::CGI::redirect($someurl)%> from within a template? I'm having trouble getting that to work... Is it because it's too late to send HTTP headers at the top of a template file? Any suggestions would be appreciated.

Yes, it's too late to send headers by the time the template is parsed/printed. You need to send them before the template is done. You can just do:

print $IN->redirect("some url");

Cheers,

Alex
--
Gossamer Threads Inc.