Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

static site/ dynamic logged in state

Quote Reply
static site/ dynamic logged in state
Is there a way to have the users logged in stats displayed on a static site?

have the .php extention on all my pages (except the user.cgi, rate.cgi etc pages)

Is there a way to do this with a snippet of php and a "if extension = .php show x" Else if extension = .cgi show y" kind of thing?

Or, is there another way? I'd like to show the user their logged in state on all pages without having to go dynamic with all the content.

Thanks!
Quote Reply
Re: [Evoir] static site/ dynamic logged in state In reply to
Don't think you can do with .php, however you should be able to do it using ssi.

Simply have a ssi include tag from the dynamic side of the site to input desired fields (in this case, username & Logged in status).

Hope this helps.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] static site/ dynamic logged in state In reply to
This sounds simple enough, but how do I do it?

Do you mean include this code as part of an ssi:
Code:
<a href="<%config.db_cgi_url%>/user.cgi<%if user.Username%>?logout=1<%endif%>" class="<%if user.Username%>in<%else%>out<%endif%>"><%if user.Username%>Logout<%else%>Login/Register<%endif%></a>

Right? So do I create a new template and include that snippet, and then call that template via ssi?

Can you help me with a code example? Thanks!

Last edited by:

Evoir: Jun 11, 2007, 4:18 PM
Quote Reply
Re: [Evoir] static site/ dynamic logged in state In reply to
Try this:
  1. Create a file with the name userstatus.html
  2. Upload this page along with your templates.
  3. Within this file add this code
    Code:
    <%if user.Username%> Hello <%user.Name%><%else%><a href="/path-to-cgi-folder/user.cgi">Sign-in</a> |
    <a href="/path-to-cgi-folder/user.cgi?signup_form=1">Register</a>&nbsp;&nbsp;<%endif%>
  4. On any page where you want to display user logged in status, add this code
    Code:
    <!--#include virtual="/path-to-cgi-folder/page.cgi?p=userstatus"-->
Just remember that SSI normally only works with pages that end with .shtml . You can also use ssi on pages ending with .html by adding below lines in your .htaccess file.
Code:
AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm

Also, in # 2, change the path so it reflects to actual path to GLinks Installation.

This should do the trick.

Hope this helps.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] static site/ dynamic logged in state In reply to
SWDevil, That was so nice of you. Worked like a charm. Except.... now the dynamic pages (search, login etc) do not show the user status..... is there a solution to this problem?
Quote Reply
Re: [Evoir] static site/ dynamic logged in state In reply to
SSI normally don't work on .cgi pages.

Simply modify your template pages that (user, login, search, search results, add, etc) and instead of
Code:
<!--#include virtual="/path-to-cgi-folder/page.cgi?p=userstatus"-->
directly add
Code:
<%if user.Username%> Hello <%user.Name%><%else%><a href="/path-to-cgi-folder/user.cgi">Sign-in</a> |
<a href="/path-to-cgi-folder/user.cgi?signup_form=1">Register</a>&nbsp;&nbsp;<%endif%>

P.S. I assume you are using 1 header file for all the pages. In your case, you might want to split it. So there will be 2 header files, one for pages that will be ending with .shtml (or .html) and other for pages with .cgi? where instead of ssi you use the code directly.

This should do it.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] static site/ dynamic logged in state In reply to
Your assumption is correct about the header file. I was thinking that route, but wasn't certain. I'll make two headers, that'll work. Thanks so much for the help. :)