Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Display Page If User Is Logged In

Quote Reply
Display Page If User Is Logged In
Hi: I have a page that I only want to show if a user is logged in- sort of like rate.cgi. If the user is not logged in, I would like them forwarded to the Log In page. I know I can do this rather inelegantly if I did a <%if Username%><%else%> on the target page... but with the way rate.cgi works, I thought there might be a better way. I would assume this would involve some editing to page.cgi. Any hints on what I should do? Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Display Page If User Is Logged In In reply to
Nevermind-- i figured it out! Blush
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Display Page If User Is Logged In In reply to
Hi,

Just FYI (anyone who wants to know in the future =)), you can "wrap" the code;

Code:
<%if user.Username%>
...show normal page
<%else%>
<%set error = "Sorry, you need to be logged in"%>
<%include error.html%>
<%endif%>

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: [Andy] Display Page If User Is Logged In In reply to
Andy: Yeah, that was my first thought.... but I liked the way rate worked better. I ended up making a new cgi script to handle JUSt this request, and put if (! $USER) {
print $IN->redirect( Links::redirect_login_url ('det_cover') );
return;
} In the script- that did it!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Display Page If User Is Logged In In reply to
Hi,

Yeah, I was going to suggest something like that. However, I'm trying get get out of the habit of modifying the core scripts (because of upgrade problems) ... so the template option is safer in that sense <G>

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: [carfac] Display Page If User Is Logged In In reply to
FWIW.... the tiny script option will survive upgrades, probably,

but

FWIW2 .... looking at what the new template parser can do, and checking out how the 'admin' template sets call functions and programs from the admin area, can give you completely new insights into how to set up something like this.

I've said for years, the GT parser is at least as good as PHP, and more secure.

They are sort of proving it with the enhanced functionality within the parser.

Rather than writing a script, you can use the Custom.pm (?) or simply put a User_Tools.pm in the plugins area, and add your various functions (similar to globals) into it.

You can then call it from within your templates. Really cool, and at least as convoluted as PHP <G> without the "holes".

BTW: The UltraWidgets Toolbox is still being rewritten, and a lot of cool code is being integrated. I have not only put in some of the small calling codes, but also am integrating things like the advanced search and keywords logger, and duplicate checking, and such that can be managed from one place. Rather than installing a bunch of little plugins, one larger one will manage all the snippets, and you can harness the power of the template parser to tap them.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Andy] Display Page If User Is Logged In In reply to
Andy: I know what you mean.... but by creating a NEW script, it is not effected by the upgrade process. I am using this on my Comic Book site... where I have a 175 pixel wide image of the cover. I decided to add a "hi-res" version of the covers (400 Px), and made it linkable... but only for Users. So the link goes to "cover.cgi". I put that link inside an <%if Username%>... But I want people to KNOW there is an enhanced image, so I added a "enlarge" text link- so I made theat link go through the Username validation... so that should hopefully drive more users!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Display Page If User Is Logged In In reply to
Hi,

Ah sorry, didn't realise it was a seperate script <G>

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!