xx1
Junior Member
Posts: 230
inherit
194450
0
Oct 8, 2024 4:39:28 GMT -8
xx1
230
May 2013
xx1
|
Post by xx1 on Jul 7, 2016 5:06:22 GMT -8
I have a drop down list of Member Sites (affiliates) at the very bottom of my home page (placed in Main Footer).
Member Sites - to add to list at bottom of page
Admin panel/Structure/Header & Footers/Main Headers and Footers add into Footer
<br> <form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option>
My issue is that I'd like this list visible only to logged in members.
Is there a way to do this?
Thanks.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Jul 7, 2016 20:15:17 GMT -8
xx1, Is that inside of a <script> tag? If so, you can put that part inside an if to see if it's a logged in member on or not. Something like: if (pb.data('user').is_logged_on) { // your code }
|
|
xx1
Junior Member
Posts: 230
inherit
194450
0
Oct 8, 2024 4:39:28 GMT -8
xx1
230
May 2013
xx1
|
Post by xx1 on Jul 8, 2016 10:03:25 GMT -8
The code: <br> <form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option>...is in my main footer. Below it I have added member urls <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option>
<option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option> <option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select></form></br>It enable a drop down list of member's sites. This I would like to hide from non members. I tried your suggestion MSG, but it did not work. Thanks for the suggestion, . Any further ideas?
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Jul 8, 2016 10:33:03 GMT -8
xx1, Is that inside of a <script> tag? If so, you can put that part inside an if to see if it's a logged in member on or not. Something like: if (pb.data('user').is_logged_on) { // your code }
Try is_logged_in.
|
|
inherit
229427
0
Jul 11, 2016 18:24:28 GMT -8
john1960
220
February 2016
john1960
|
Post by john1960 on Jul 8, 2016 18:21:01 GMT -8
xx1 , Is that inside of a <script> tag? If so, you can put that part inside an if to see if it's a logged in member on or not. Something like: if (pb.data('user').is_logged_on) { // your code }
Try is_logged_in. This is great and can this be added to the navigation bar under ones banner? I use this code to make these buttons: <script type="text/javascript"> fContent.push(document.getElementById('last-thread').innerHTML); fContent.push(document.getElementById('newest-user').innerHTML); fContent.push(document.getElementById('total-members').innerHTML); fContent.push(document.getElementById('total-posts').innerHTML); </script> I tried to put the above code in with this but no luck I could put it below the navigation bar but it would be nice to add it with the other buttons? Test Forum: scootproftest.freeforums.net/
|
|
xx1
Junior Member
Posts: 230
inherit
194450
0
Oct 8, 2024 4:39:28 GMT -8
xx1
230
May 2013
xx1
|
Post by xx1 on Jul 9, 2016 4:58:45 GMT -8
Hi Todge,
It is still not working for me.
Here is what I have in the Main Footer:
<form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option> <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option>
<option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option>
<option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select></form></br>
This works fine.
Now I want to hide it from non members or those not signed in.
I put this at the front: if (pb.data('user').is_logged_in) { // and this at the end: }
So it looks like this:
if (pb.data('user').is_logged_in) { // <form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option> <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option>
<option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option>
<option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select></form></br> }
This does not hide the member list from those not logged in. Does the code look right? I may not have done it correctly.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Jul 9, 2016 11:54:17 GMT -8
Is your code inside of <script> tags? For example, does your entire piece of code above look like this: <script> if (pb.data('user').is_logged_in) {
<form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option> <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option> <option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option> <option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select> </form> </br> } </script>
You said your code was in your Main Footer. JavaScript needs to be inside of <script> tags to properly work there. It may also be prudent (if that is your entire code) to have it wait for document.ready. This is how I would have this added in: <script> $(document).ready(function() { if (pb.data('user').is_logged_in) { <form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option> <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option> <option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option> <option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select> </form> </br> }; }); </script>
Don't mind the indentation - I only did that for readability (for me). If that doesn't work, maybe I missed something and perhaps Todge could take a quick look. Also, without knowing if this segment is actually a piece of a larger code, you might already have the <script> tags and the document.ready there somewhere. If that is the case, then what I did above could cause issues - such as nested <script> tags if you've already got them. So, I guess the important question is: is your code above the code in its entirety, or is it just a segment of a larger piece of code?
|
|
xx1
Junior Member
Posts: 230
inherit
194450
0
Oct 8, 2024 4:39:28 GMT -8
xx1
230
May 2013
xx1
|
Post by xx1 on Jul 9, 2016 13:27:17 GMT -8
MSG, I removed what was in my Main Footer, and replaced it with your last code: <script> $(document).ready(function() { if (pb.data('user').is_logged_in) { <form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option> <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option> <option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option> <option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select> </form> </br> }; }); </script>With this in place, my member sites do not appear at all. Then I replaced it with my original code: <form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option> <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option>
<option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option>
<option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select></form></br>My member sites list appears, but is visible to un-logged in users. Here is the url to my forum. The member's list is at the very bottom left of the main page. whistlestopcafeii.freeforums.net/Help!
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Jul 9, 2016 14:10:00 GMT -8
xx1, Okay. I tossed this on my work forum to see what I could do. Since you have this in your Main Footer, that means you are having it show on only your Home page. Here is what I did to make it work: (1) Remove the code from the Main Footer (2) Go to Admin > Structure > Layout Templates > Home template(3) At the very bottom, you should see an {/if} - create a new line under that (4) Paste this in: {if $[current_user.is_member]} <form name="jump"> <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO"> <option value="">Member Sites</option> <option value=http://nicetomeet.proboards.com/>Friendly Faces (ToeTapping)</option> <option value=http://thelonelyheartsclub.freeforums.net/>The Lonely Hearts (Apple)</option> <option value=http://gibbysplace.freeforums.net/forum/>Gibby's Place</option>
<option value=http://oznewsandviews.proboards.com/>News and Views Australia (bass)</option> <option value=http://sassys.proboards.com/>Whispering Minds (Sassy)</option> <option value=http://communitylibrary.proboards.com/> Our Community Library (foxy)</option>
<option value=http://samanthastone.proboards.com/> HomeTalk Break (Smo)</option> </select></form></br> {/if}
Let me know how that works for you.
|
|
inherit
229427
0
Jul 11, 2016 18:24:28 GMT -8
john1960
220
February 2016
john1960
|
Post by john1960 on Jul 9, 2016 15:53:38 GMT -8
That works well Lynx for me and you can place it in different places in the Home template to move it around. It also as you said will not show if you are logged out. Great job!
|
|
xx1
Junior Member
Posts: 230
inherit
194450
0
Oct 8, 2024 4:39:28 GMT -8
xx1
230
May 2013
xx1
|
Post by xx1 on Jul 10, 2016 12:37:42 GMT -8
MSG, I followed your instructions... and it works perfectly!
Thanks so much.
xx1
|
|