Printable Version of Topic
Click here to view this topic in its original format
Jcink.com Forums > General Support > Removing Empty MiniProfile Fields [SOLVED]


Posted by: DesiTack Apr 16 2018, 03:12 AM
There are two fields in my miniprofile that can be left blank, and I'd like to remove them when they are blank. I've done some looking around to find out how to do this. So far, this is how I have it coded.

HTML templates:
CODE
<span class='minigames'><p class="mpInfo"><span class="fctitle">Games</span> <!-- |field_18| --></p></span>
<span class='mininick'><p class="mpInfo"><span class="fctitle">Nickname</span> <!-- |field_7| --></p></span>


CSS under <% BOARD %>
CODE
<script>$('.mininick:contains("N/A")').remove();</script>
<script>$('.minigames:contains("N/A")').remove();</script>


I've seen this works for others, but I can't get it to work for me.

Posted by: John Apr 16 2018, 03:47 AM
Try this conditional instead:

CODE
if('<!-- |field_18| -->' != '') { document.write('<span class="minigames>"<p class="mpInfo"><span class="fctitle">Games</span> <!-- |field_18| --></p></span>'); }</script>


It will work better for this use case;

Also a small note; MP fields don't output N/A anymore they just return empty.

Posted by: DesiTack Apr 16 2018, 04:21 AM
Okay, so I don't know if I have this plugged in right, I'm pretty new to javascript.

I now have
CODE
<script>if('<!-- |field_18| -->' != '') { document.write('<span class="minigames>"<p class="mpInfo"><span class="fctitle">Games</span> <!-- |field_18| --></p></span>'); }</script>
<script>if('<!-- |field_7| -->' != '') { document.write('<span class="mininick>"<p class="mpInfo"><span class="fctitle">Nickname</span> <!-- |field_7| --></p></span>'); }</script>


under <% BOARD %>. Which I can't have done it right, because it's not working. lol

Posted by: John Apr 17 2018, 11:01 AM
Not under <% BOARD %>, that must be placed in Mini Profile. Put it in place of where the field HTML currently is.

Posted by: DesiTack Apr 17 2018, 05:11 PM
I edited the script a little and plugged in

CODE
<script>if('<!-- |field_18| -->' != '') { document.write('<p class="mpInfo"><span class="fctitle">Games</span> <!-- |field_18| --></p>'); }</script>
            <script>if('<!-- |field_7| -->' != '') { document.write('<p class="mpInfo"><span class="fctitle">Nickname</span> <!-- |field_7| --></p>'); }</script>


and this is working perfectly now!
Thanks so much for your help, John!

Posted by: John Apr 18 2018, 01:31 AM
This topic has been solved. If you need anymore help please post a new thread. Thanks for choosing Jcink services.

'
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)