inherit
238893
0
Mar 15, 2022 16:18:19 GMT -8
Crab
71
November 2016
thedestinedcrab
|
Post by Crab on Nov 13, 2016 15:16:56 GMT -8
Hi,
I'm trying to make a small plugin project, i've been working the whole day either learning JS or coding this small project.
I'm stuck on something that I knownis really simple, can someone please help me and correct my code?
My code :
{if$[current_user.is_guest] function hide { document.getElementById('clicker_div').style.display = "none"; } {/if}
So i'm trying to say, if they are a guest then hide div clicker_div
Can someone please explain what i'm doing wrong and how to rectify this issue?
Cheers Crab.
|
|
Kami
Forum Cat
Posts: 40,020
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,020
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Nov 13, 2016 15:36:07 GMT -8
This is not a plugin issue, your syntax is wrong. First of all:
{if $[current_user.is_guest]}
^ note the space and end bracket
Second of all all javascript MUST be between <script> tags.
Lastly, this is unnecessary, you can just put the div in a member statement
{if $[current_user.is_member]}
clicker div here
{/if}
|
|
inherit
238893
0
Mar 15, 2022 16:18:19 GMT -8
Crab
71
November 2016
thedestinedcrab
|
Post by Crab on Nov 13, 2016 23:02:13 GMT -8
Ahh, I was over complicating it Thankyou so much, I'll fix my code later today
|
|
Kami
Forum Cat
Posts: 40,020
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,020
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Nov 13, 2016 23:13:40 GMT -8
Ahh, I was over complicating it :D Thankyou so much, I'll fix my code later today :) You're welcome!
|
|
inherit
238893
0
Mar 15, 2022 16:18:19 GMT -8
Crab
71
November 2016
thedestinedcrab
|
Post by Crab on Nov 14, 2016 0:19:19 GMT -8
Problem.. This is my code : It's currently only meant to display an image if they are a member. It's not displaying an image at all.. Why is that?
|
|
Kami
Forum Cat
Posts: 40,020
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,020
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Nov 14, 2016 0:38:07 GMT -8
OH. Okay so. I totally misunderstood you. Based on your post using the {if} variables I assumed you were working in templates, rather than building a plugin from scratch, my mistake! You can't use template variables outside of the templates like that. I'm not really all that familiar with Javascript, but it's my understanding that you will have to write a js code that will include the 'if member' component in js syntax, rather than in template syntax. www.proboards.com/developer/js^ Here is the proboards js API. It looks like the format you'll want to use is: pb.NAME_OF_CLASS.NAME_OF_FUNCTION(PARAMETERS);So my best guess would be something along the lines of: pb.current_user.is_member(div here);I'm not entirely 100% sure that's correct, but that'll be the direction you'll want to head in. Tagging a few members that might be able to help you out: Chris, Peter
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,285
January 2004
todge
|
Post by Todge on Nov 14, 2016 13:07:22 GMT -8
Or even..
if(pb.data('user').is_logged_in == 1)
and close the if statement with..
}
rather than {/if}
|
|
inherit
238893
0
Mar 15, 2022 16:18:19 GMT -8
Crab
71
November 2016
thedestinedcrab
|
Post by Crab on Nov 14, 2016 13:24:53 GMT -8
Or even.. if(pb.data('user').is_logged_in == 1) and close the if statement with.. } rather than {/if}I'll try this now, thanks
|
|