Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Need SOme Help With The Dynamic Log In on Static

Quote Reply
Need SOme Help With The Dynamic Log In on Static
Hi:

Using Java to add a Log In or Log Out on static is a great idea. Unfortunately, I seem to be missing something on my static pages- I am getting just a "Log In" even if I am logged in!

I have this in the header:

Code:

<%if not d and not user.Username~%>
<script type="text/javascript" src="<%config.build_static_url%>/utils.js"></script>
<script type="text/javascript">
//<![CDATA[
registerEvent(window, 'onload', function () {
var loginbar = document.getElementById('loginbar');
if (!loginbar)
return;
var loginlink = loginbar.firstChild;
if (loginlink.className != 'out')
return;
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
if (cookies.match(/<%config.user_cookie_prefix%>s=[0-9a-f]+/)) {
loginlink.href = '<%config.db_cgi_url%>/user.cgi?logout=1';
loginlink.className = 'in';
loginlink.firstChild.nodeValue = 'Logout';
break;
}
}
});
//]]>
</script>
<%~endif%>


And <script type="text/javascript" src="http://www.bcdb.com/cartoons/static/utils.js"></script> is in the header, and the file exists. So I THINK that part is fine!

So, in the page, I have:

Code:


&nbsp;&nbsp;<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>


WHich I think is right... but probably I am missing something.

Well, I just get Login/Register, even when I am loggen in when I check.

What am I missing????
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Need SOme Help With The Dynamic Log In on Static In reply to
You have totally changed the templates and thus the javascript (not java) does not work. The javascript requires that the div with id of loginbar exists and that the Login/Logout link is the first element in the #loginbar div. You're going to have to rewrite it to work in your case.

Adrian
Quote Reply
Re: [brewt] Need SOme Help With The Dynamic Log In on Static In reply to
OK, that is easily doable!

I figured it was something like that...
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [brewt] Need SOme Help With The Dynamic Log In on Static In reply to
Adrian:

Just wondering whether the script that goes into the header for the login can be called like this:-

Code:
<%if not d and not user.Username~%>
<script type="text/javascript" src="<%config.build_static_url%>/utils.js"></script>
<script type="text/javascript" src="<%config.build_static_url%>/login.js"></script>
<%~endif%>

rather than loading it in the page.


Thanks,



Clint.
--------------------------
http://AffiliatesDirectory.com
The Affiliate Programs Directory
Quote Reply
Re: [Clint] Need SOme Help With The Dynamic Log In on Static In reply to
Yes, but you have to replace the GT::Template tags in the script with your system's actual variables (since it won't get parsed by GT::Template when included like that).

Adrian
Quote Reply
Re: [brewt] Need SOme Help With The Dynamic Log In on Static In reply to
Thanks Adrian:

I take it you mean to replace:-

<%config.build_static_url%>/login.js to ....
/actual/path/to/login.js

Am I right?


Thanks,


Clint.

--------------------------
http://AffiliatesDirectory.com
The Affiliate Programs Directory
Quote Reply
Re: [Clint] Need SOme Help With The Dynamic Log In on Static In reply to
No, the tags in the content that you're moving into the js.

Adrian
Quote Reply
Re: [brewt] Need SOme Help With The Dynamic Log In on Static In reply to
Hi Adrian,

I have a related question. We are using static pages (Links 3.0.4) together with GT Community to handle user logins. With this combo the javascript Login/Logout Toggle do not work. What changes need to be made?

Thanks in advance!

Peter
Quote Reply
Re: [meta500] Need SOme Help With The Dynamic Log In on Static In reply to
Hi Peter:

I've actually had a re-think and am using the default code (from Luna) on dynamic pages for login/logout and am using SSI to achieve the same thing on static pages.

Works like a charm, and after playing with the Javascript option have found this combination works the best.

Regards,

Clint.
--------------------------
http://AffiliatesDirectory.com
The Affiliate Programs Directory
Quote Reply
Re: [Clint] Need SOme Help With The Dynamic Log In on Static In reply to
Thanks Clint, but I am not sure how SSI on static pages could change anything for me?

I use unmodified Luna Links templates and the default (unmodified) Community templates. I just want the javascript toggle to work with static pages and the Community login.
Quote Reply
Re: [meta500] Need SOme Help With The Dynamic Log In on Static In reply to
I haven't worked with Community, but it looks like it overrides glinks' authentication modules, so glinks' normal cookies won't exist when logging in through Community. Try changing this in include_common_head.html:
Code:
if (cookies[i].match(/^\s*<%config.user_cookie_prefix%>s=[0-9a-f]{32}\s*$/)) {
to
Code:
if (cookies[i].match(/^\s*community_cookie_name_here=[0-9a-f]{32}\s*$/)) {
I believe Community uses the cookie name Community_Session.

Adrian

Last edited by:

brewt: Nov 7, 2005, 3:49 PM
Quote Reply
Re: [brewt] Need SOme Help With The Dynamic Log In on Static In reply to
Yep, that did the trick.
Thank you very much, Adrian!

Peter
Quote Reply
Re: [brewt] Need SOme Help With The Dynamic Log In on Static In reply to
Hi Adrian,

I didn't really follow this discussion but was wondering if this mod should be done in general for people that use Community with Links or just people that have static pages in Links and use Community ?

Thanks,

John
Significant Media
Quote Reply
Re: [Jag] Need SOme Help With The Dynamic Log In on Static In reply to
Only if you're using static pages with Community, since that javascript is only used on static page builds.

Adrian