jfb-skinning-profile-templates [Jcink.com Wiki]

Differences

This shows you the differences between the selected revision and the current version of the page.

jfb-skinning-profile-templates 2018/07/05 12:24 jfb-skinning-profile-templates 2018/09/23 06:13 current
Line 80: Line 80:
There are other things you can do as well, the possibilities are virtually endless. There are other things you can do as well, the possibilities are virtually endless.
-==== Using Javascript ==== +==== Using Javascript Conditionals ==== 
-Javascript can be placed inside this section also. However one important thing to know about using javascript here is that any code cannot be broken up by use of the enter key. So for example in this code to only show custom fields if they're not blank or N/A:+ 
 +You can use javascript conditionals with variables, in the example below a conditional is used to check to see if a field is blank/inputted by the user or. If it isn't blank, then it writes (document.write) the field into the profile.
<code> <code>
<script> <script>
-if("<!-- |field_1| -->" != "N/A") {  +if("<!-- |field_1| -->" != "") {  
-document.write('<a href="<!-- |field_1| -->">Character sheet</a>'); +document.write('<a href="<!-- |field_1| -->">Test</a>');
} }
</script> </script>
</code> </code>
-This code (shown above) will fail. This is because using the enter key causes the compiler to place in <br> which breaks the code up and stops it from working. So for Javascript to work there all codes must be all on 1 line. (This doesn't mean they can't spill over onto multiple lines, it just means they cannot have the enter key used on them. Formatting-wise, Javascript interpreters will read parse it whether it's on one line or 5. It's primarily broken up simply to make it easier to read for people.)  
-So a working version of this code would be+There are many more conditionals you can create, the possibilties are endless as long as you have the right variables. Here are some other examples: 
-<code><script>if("<!-- |field_1| -->" != "N/A") { document.write('<a href="<!-- |field_1| -->">Character sheet</a>');}</script></code>+ 
 +==== Display profile field (specific group) ==== 
 + 
 +<code> 
 +<script> 
 +if("<!-- |field_1| -->" != "" && "<!-- |g_id| --> " == "4") {  
 +document.write('<a href="<!-- |field_1| -->">Test</a>');  
 +} 
 +</script> 
 +</code>
-So if your Javascript codes placed in here aren't working properly, try removing spaces in them where ever you can to see if an accidental enter key press is causing problems.+Change the "4" (the root admin grup in this example) to only display field_1's contents to a group ID of your choice.
 
jfb-skinning-profile-templates.1530807846.txt.gz · Last modified: 2018/07/05 12:24 by jcink