vForums Support > Programming & Coding :: Code Requests & Support :: > [Request] Guest friendly message

[Request] Guest friendly message - Posted By Nick (nickb) on 29th Oct 08 at 5:53pm
I would like to have a "Guest Friendly Message" script, it is only viewable to guests, but when guests login or register the whole "Guest friendly message" table disappears. Now this is what I want:

http://i185.photobucket.com/albums/x20/magedesigns/misc/guest_view.png

That is exactly how I want it. Plus the login will have its time to be logged in. As well as a <a href="/action/register">[register]</a> link. Above it.

It would be much appreciated.

(I would do this myself by I am having trouble I know some scripting but not that good.)

Thanks,
Darkmage


Re: [Request] Guest friendly message - Posted By ashkir (ashkir) on 29th Oct 08 at 6:07pm
Darkmage, remember that code I PM'd you, why not code a table in the guest part and leave the member part blank?

Re: [Request] Guest friendly message - Posted By Nick (nickb) on 29th Oct 08 at 6:15pm
o_0 I did not think of that. Thanks! I will try that. I forgot all about it. {Unsure}

But what about the Login field? Some scripting needs to go into that.

edit:
Not working {Unsure}
http://vfad.vforums.co.uk/

I put it in Global Header

Re: [Request] Guest friendly message - Posted By dog199200 (dog199200) on 31st Oct 08 at 11:46am
I'm not saying this is exactly what you are looking for but something like this? I'm can edit it any way if needed:

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Guest Friendly Message by Dwight
  5. Copyright© 2008 Infinity Codes
  6. http://icodes.vforums.co.uk
  7. Do not Repost
  8. */
  9.  
  10. //Edit Below
  11.  
  12. var wtp = 2; //0 = above banner, 1 = above menu buttons, 2 = below menu buttons
  13.  
  14. //Edit Above
  15.  
  16. function login(){
  17.     get('username','name')[0].value = get('un','id').value;
  18.     get('password','name')[0].value = get('pw','id').value;
  19.     get('loginForm','name')[0].submit();
  20. }
  21.  
  22. function build(){
  23. var wt = document.getElementById("welcome_table");
  24. var nRow=wt.insertRow(wtp);
  25. var nCell=nRow.insertCell(0);
  26. nCell.className="window1";
  27.  
  28. nCell.innerHTML = 'We hope you enjoy your visit.<br /><br /><br />You’re currently viewing the our forum as a guest. This mean you are limited to certain areas of the board and there are some features you can not use. If you join our community, you’ll be able to access the member-only sections, and use many member-only features such as customizing your profile, sending private messages, and voting in polls. Registration is simple, fast, and completely free.<br /><br /><br /><font color="#FF6600">Join our community! <a href=/action/register>Register Now!</a></font><br /><br /><br />If you are already a member please login to your account to access all the features:<br /><form action=javascript:void(0); onsubmit=login();>Username: <input type="text" id="un" size="20"> Password: <input type="password" id="pw" size="20"><input type="submit" value="Login"></form>';
  29. }
  30. //-->
  31. </script>
  32.  
  33. <script>
  34. if(location.href.match(/.co.uk($|\/$)/) && vf_username == 'guest'){
  35.     build();
  36.     get('loginForm','name')[0].firstChild.style.display = 'none';
  37.     get('loginForm','name')[0].parentNode.previousSibling.style.display = 'none';
  38.     get('loginForm','name')[0].parentNode.nextSibling.style.display = 'none';
  39. }
  40. </script>
 


I hope this is what you where looking for. I wasn't sure if you wanted the message in an another table or not so I just combined it into the welcome table, giving you the option of placing it either above the banner, or above or bellow the menu buttons. {Smile} Should sound familiar. As well I took the base of the vb quick login code so it only shows for a guest. The only thing though is that it only shows on the main page, no where else, at least for now, though just by remove the

($|\/$)

from the

if(location.href.match(/.co.uk($|\/$)/)

you can make it show on every page, but I am currently working on getting it so that it will not show on the login page of the register page. Well I hope this works for you {Smile}

For a Preview, check the IFC test forum

Edit: I forgot to add that I am currently recoding it a bit to make it a bit easier to edit

Re: [Request] Guest friendly message - Posted By Nick (nickb) on 31st Oct 08 at 8:32pm
Thanks Dwight {Smile} I can use this one until you get the other one fixed.

edit
But look what happens:
http://i185.photobucket.com/albums/x20/magedesigns/misc/vf_ad_preview.jpg

Re: [Request] Guest friendly message - Posted By dog199200 (dog199200) on 1st Nov 08 at 9:28pm
recopy the code above

Re: [Request] Guest friendly message - Posted By Nick (nickb) on 2nd Nov 08 at 4:42am
Still the same.

Re: [Request] Guest friendly message - Posted By dog199200 (dog199200) on 11th Nov 08 at 6:08am
OK here is the fixed version of the code, as well as the array:

Code:
 
  1. <script type="text/javascript">
  2. /*
  3. Guest Friendly Message by Dwight
  4. Copyright© 2008 Infinity Codes
  5. http://icodes.vforums.co.uk
  6. Do not Repost
  7. */
  8.  
  9. //Edit Below
  10.  
  11. var wtp = 2; //0 = above banner, 1 = above menu buttons, 2 = below menu buttons
  12.  
  13. var message = ['We hope you enjoy your visit.<br /><br /><br />You re currently viewing the our forum as a guest. This mean you are limited to certain areas of the board and there are some features you can not use. If you join our community, you ll be able to access the member-only sections, and use many member-only features such as customizing your profile, sending private messages, and voting in polls. Registration is simple, fast, and completely free.<br /><br /><br /><font color="#FF6600">Join our community! <a href=/action/register>Register Now!</a></font><br /><br /><br />If you are already a member please login to your account to access all the features:']; // Do not use 's, they will cause the code to break.
  14.  
  15. var form = ['<form action=javascript:void(0); onsubmit=login();>Username: <input type="text" id="un" size="20"> Password: <input type="password" id="pw" size="20"> <input type="submit" value="Login"></form>'];
  16.  
  17. //Edit Above
  18.  
  19. function build(){
  20. var wt = document.getElementById("welcome_table");
  21. var nRow=wt.insertRow(wtp);
  22. var nCell=nRow.insertCell(0);
  23. nCell.className="window1";
  24. nCell.innerHTML = message + "<br />" + form;
  25. }
  26. function login(){
  27.     get('username','name')[0].value = get('un','id').value;
  28.     get('password','name')[0].value = get('pw','id').value;
  29.     get('loginForm','name')[0].submit();
  30. }
  31. if(location.href.match(/.co.uk/) && vf_username == 'guest'){
  32.     build();
  33. }
  34. </script>