inherit
194230
0
Nov 21, 2015 5:56:42 GMT -8
Alan Vende
4,215
May 2013
l1o2u3i4s5
|
Post by Alan Vende on Mar 16, 2018 7:16:17 GMT -8
Hello!
I'm drawing a blank on this one. I know of the display: none; property, but is it possible to place something within the area in which you have the display: none;?
As an example, I have a plugin that I'm working on where some areas of it don't have information yet, so I wanted to put display: none; on the information that's there, and put a p tag of "There's nothing available here yet. Check back later."
Is it possible to do that in a plugin? I know it is in the templates with {if} statements, but wasn't sure if it was possible in a plugin.
Thanks, all!
|
|
#e61919
Support Staff
224482
0
1
May 1, 2024 15:57:15 GMT -8
Scott
23,320
August 2015
socalso
|
Post by Scott on Mar 16, 2018 7:31:54 GMT -8
Alan Vende, have you tried it? Any code you put in a plugin you should be able to infuse into the forum via the layout templates, css, or headers/footers - so if you can do it in a template you should be able to do it in a plugin with the exception of using the template variables. (Or so is my understanding )
|
|
inherit
194230
0
Nov 21, 2015 5:56:42 GMT -8
Alan Vende
4,215
May 2013
l1o2u3i4s5
|
Post by Alan Vende on Mar 16, 2018 7:44:49 GMT -8
Alan Vende , have you tried it? Any code you put in a plugin you should be able to infuse into the forum via the layout templates, css, or headers/footers - so if you can do it in a template you should be able to do it in a plugin with the exception of using the template variables. (Or so is my understanding ) I was trying to edit the post as I had posted it too quickly. But yes, I have I got as far as {if} and then blanked as there's no variable within the UI to reference. Looking at Brian's plugin as an example, he used an {if} statement with a variable from the UI. What I forgot to say is that I'm working strictly within the Components area, not using the UI at all. Every {if} statement I see has a variable within it from the UI. So, I guess I should have phrased my question differently: Is it possible to use an {if} statement if there's no variable in the UI to use with it?
|
|
#e61919
Support Staff
224482
0
1
May 1, 2024 15:57:15 GMT -8
Scott
23,320
August 2015
socalso
|
Post by Scott on Mar 16, 2018 8:02:00 GMT -8
Alan Vende , have you tried it? Any code you put in a plugin you should be able to infuse into the forum via the layout templates, css, or headers/footers - so if you can do it in a template you should be able to do it in a plugin with the exception of using the template variables. (Or so is my understanding ) I was trying to edit the post as I had posted it too quickly. But yes, I have I got as far as {if} and then blanked as there's no variable within the UI to reference. Looking at Brian's plugin as an example, he used an {if} statement with a variable from the UI. What I forgot to say is that I'm working strictly within the Components area, not using the UI at all. Every {if} statement I see has a variable within it from the UI. So, I guess I should have phrased my question differently: Is it possible to use an {if} statement if there's no variable in the UI to use with it?Why not? (Then again I probably have no idea what I'm talking about. ) Tagging Brian to tap in here.
|
|
#eb7100
33409
0
1
May 1, 2024 1:31:09 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Mar 16, 2018 8:15:11 GMT -8
The variables available for you to use in your components are going to be determined by what you've added to the plugin's UI.
You can make an if statement using a nonexistent variable but the if statement will always fail and the contents you place inside of it will never render so it's kind of pointless.
|
|
inherit
194230
0
Nov 21, 2015 5:56:42 GMT -8
Alan Vende
4,215
May 2013
l1o2u3i4s5
|
Post by Alan Vende on Mar 16, 2018 8:34:57 GMT -8
I was trying to edit the post as I had posted it too quickly. But yes, I have I got as far as {if} and then blanked as there's no variable within the UI to reference. Looking at Brian's plugin as an example, he used an {if} statement with a variable from the UI. What I forgot to say is that I'm working strictly within the Components area, not using the UI at all. Every {if} statement I see has a variable within it from the UI. So, I guess I should have phrased my question differently: Is it possible to use an {if} statement if there's no variable in the UI to use with it?Why not? (Then again I probably have no idea what I'm talking about. ) Tagging Brian to tap in here. I just always thought {if} statements required variables. Unless I don't fully remember how to use an {if} statement, and I'm misconstruing them? I haven't used one in a long, long time, which is partly why I asked here. I just always thought an {if} statement required a variable of some sort, like in Brian's plugin, for example. His variable is from his UI section. Because, I don't remember being able to use just {if}. If you do that, there's nothing for it to reference, if I understand it correctly. As an example, one of the {if} statements that I have from my templates is: {if $[user.group.name] == "Head Administrator"}{/if} Granted, that could probably be used with the plugin, too, but like I said, for this I think it needs a variable that's from within the plugin. But, like I said, I'm not sure... This is the first time I've ventured into {if} statements in a plugin. The variables available for you to use in your components are going to be determined by what you've added to the plugin's UI. You can make an if statement using a nonexistent variable but the if statement will always fail and the contents you place inside of it will never render so it's kind of pointless. I thought so. Thanks, Brian. So, I'm guessing there would be no way to do what I want without using the UI?
|
|
#e61919
Support Staff
224482
0
1
May 1, 2024 15:57:15 GMT -8
Scott
23,320
August 2015
socalso
|
Post by Scott on Mar 16, 2018 8:45:09 GMT -8
Alan Vende, well based on Brian's response, told you I didn't know what I was talking about. I'm only on chapter 3 of my JS learning.
|
|
#eb7100
33409
0
1
May 1, 2024 1:31:09 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Mar 16, 2018 8:45:50 GMT -8
Plugins can only use variables from the user interface, so if you need an if statement for any reason your only choice is to use a variable you've added to the plugin.
|
|
inherit
194230
0
Nov 21, 2015 5:56:42 GMT -8
Alan Vende
4,215
May 2013
l1o2u3i4s5
|
Post by Alan Vende on Mar 16, 2018 8:54:07 GMT -8
Alan Vende , well based on Brian's response, told you I didn't know what I was talking about. I'm only on chapter 3 of my JS learning. You'll get there! Keep at it! ^.^ Plugins can only use variables from the user interface, so if you need an if statement for any reason your only choice is to use a variable you've added to the plugin. I was thinking of an {if} statement because the display: none; did what it's supposed to, but what I wanted was to have text there when there wasn't anything there to say "We currently have no positions filled." or something along those lines. Now that I think about it, would JS be used for this sort of thing? If so, I'm up a creek without a paddle.
|
|
#eb7100
33409
0
1
May 1, 2024 1:31:09 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Mar 16, 2018 9:25:34 GMT -8
I don't know because I don't understand what you're trying to do. You say there's no information, but then you say you want to add display: none; to the information that's there, implying that there is information.
If you're just trying to hide something from view place it inside an element with display: none; CSS. If you want to prevent its HTML from being shown in the page's source at all that's something only an if statement within an HTML component can do.
|
|
inherit
194230
0
Nov 21, 2015 5:56:42 GMT -8
Alan Vende
4,215
May 2013
l1o2u3i4s5
|
Post by Alan Vende on Mar 16, 2018 9:44:10 GMT -8
I apologize, Brian . I have a few tables in the tabs of my plugin, but some of the tables have no information to go into them besides "placeholder" text, so I wanted to hide them and have something else there until we get staff for those positions, such as a message saying "We have no members filling this staff position at this time." I remembered that that was possible with an {if} statement in the templates and whatnot, which is why I thought that was the same for a plugin. I got the tables to hide something, but then put a message in its place. Does that make sense? I have been creating this plugin on and off for about a year. In the beginning, I didn't realize that the UI could be used. I was coding it straight from the components, as that's what we were using at one point: a template mod, so I was refining that, not really thinking about using the UI. Not to mention I don't really know how to implement the UI effectively.
|
|
inherit
194230
0
Nov 21, 2015 5:56:42 GMT -8
Alan Vende
4,215
May 2013
l1o2u3i4s5
|
Post by Alan Vende on Mar 19, 2018 4:24:49 GMT -8
Brian : I did some digging and found some JS that could probably work: JavaScript If...Else Statements and JS Can Hide HTML Elements/JS Can Show HTML Elements, but I'm unsure. Is it possible to write a condition for something like what I want to do (display a message if there is no information in a table. Otherwise, display the table)? I could follow the examples, but was unsure how to write a condition like that. Also, would I write multiple statements (one for each tab/table), or could I write one and have multiple selectors like the following template mod: {elseif $[user.group.name] == "Administrator" || $[user.group.name] == "Global Moderator" || $[user.group.name] == "Moderator" || $[user.group.name] == "Graphics Guru" || $[user.group.name] == "Spiritual Advisor"} Is that possible in JS, or must they be separate if/else statements?
|
|
#eb7100
33409
0
1
May 1, 2024 1:31:09 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Mar 19, 2018 7:46:52 GMT -8
Javascript if statements and layout template if statements support the same operators, so yes.
I believe you've already used if statements like this in the Custom Mini-Profile Creator plugin.
|
|
inherit
194230
0
Nov 21, 2015 5:56:42 GMT -8
Alan Vende
4,215
May 2013
l1o2u3i4s5
|
Post by Alan Vende on Mar 19, 2018 8:45:34 GMT -8
Oh, they do? I didn't realize that; thank you! I did? That's another thing I didn't realize. What I'm struggling with most now is how to write "custom" conditions. Is it possible to write one for something like that? Do you mean an if statement like this? if(user.group){ if(user.group.name == "Head Administrator"){ $(this).append('<div class="staff_diamond"><a target="_blank" href="http://psychic-psyghtings.proboards.com/thread/755/new-badges-on-mini-profiles"><img src="http://storage.proboards.com/6033396/i/z0ia563wclNdTJSvDxFq.png"></a></div>'); } } Like I said, what I'm struggling with is that I don't have any variables or anything like that... And I've already tried things like this this weekend/morning: if (.staff-position-vacant) { $(this).append('<div class="staff_diamond"><a target="_blank" href="http://psychic-psyghtings.proboards.com/thread/755/new-badges-on-mini-profiles"><img src="http://storage.proboards.com/6033396/i/z0ia563wclNdTJSvDxFq.png"></a></div>'); } else { test }
but that displays nothing so, because of that, I'm guessing that's wrong. And, I'm also guessing I'm nowhere close, am I? I'm just struggling as I have no rank or anything constant to go with. I have the class of the areas that have nothing in it ( .staff-position-vacant), but it broke the plugin again. So, my only guess is that that's not right or close: It's probably not right because $(this) is only able to be used in the Custom Mini-Profile Creator Plugin, correct? I wanted to use the class somehow because the tab will only contain it if there aren't any staff members within that tab. That's the only time in which I want to have the message display: when we have no staff members for the positions. But is it possible to make it so it is a conditional of a class name? Like I said, the above doesn't render. So, I guess I just don't know how to write it correctly.
|
|
#eb7100
33409
0
1
May 1, 2024 1:31:09 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Mar 19, 2018 9:00:43 GMT -8
What are you looking to do, and what condition needs to be met for the change to happen?
|
|