Dyr
Junior Poster
Posts: 36
|
Post by Dyr on Jul 24, 2011 14:22:53 GMT
Could someone give me a quick example of how I would go about making my navigation links change according to who it is? (guest, members, admin) I know that you must use if(pb_username=="guest" code to show links for guests only, but don't exactly know how I'd go about it. I'd love a short example involving, say, a login link? If it's a guest, the link is "login" and if it is a member, the link is "logout". Thank you!
|
|
Nick
VIP
v5 Beta Tester[M:5000]
Philadelphia Eagles: 8-8
Posts: 2,239
|
Post by Nick on Jul 24, 2011 15:12:33 GMT
|
|
Dyr
Junior Poster
Posts: 36
|
Post by Dyr on Jul 24, 2011 17:08:12 GMT
First off, thanks for the speedy reply! I just have a couple questions. I made my navigation in an obscure spot, and hid the welcome table/pm bar. I noticed this code you gave me would essentially set up to work in the welcome table if i understand it correctly. Is there anyway I could change locations, so instead of having it locate there I could possibly make an id so I can just insert the div where I please? Or if you have an easier option in mind, I'm all ears.
Thank you very much for taking the time to help me understand this!
|
|
Nick
VIP
v5 Beta Tester[M:5000]
Philadelphia Eagles: 8-8
Posts: 2,239
|
Post by Nick on Jul 24, 2011 19:30:55 GMT
I haven't played with JS that much lately, but does this work for you?
<script type="javascript"> <!-- var fontSize = "2" var gname = "Guest" var get = document.getElementsByTagName("TD") get[2].style.display= "none" var guestMessage = '<font size='+fontSize+'><center>Welcome '+gname+', Please <a href=index.cgi?action=login>Login</a> or <a href=index.cgi?action=register>Register</a></center></font>' var pmNew = get[2].innerHTML.split(' are new')[0].split(',')[3] var memberMessage = '<font size='+fontSize+'><center>Welcome <a href="/index.cgi?action=viewprofile">'+pb_displayname+'</a>, You Have <a href="/index.cgi?action=pm">'+pmNew+' New Message(s)</a>.</center></font>' document.write( '<center><table class="catbg" width="92%"><tr><td> '); if(get[3].innerHTML.match(/Guest/i)){ document.write(guestMessage); } else { document.write(memberMessage); } document.write( '</td></tr></table></center>' ); --> </script>
|
|