PDA

View Full Version : Need help with elseif contitional for single-selection radio buttons


archet1337
07-24-2011, 02:14 PM
Hi,

I'm hoping this is the correct forum for asking this.

I have added a custom profile field with a single-selection radio button with the options "No" and "Yes". These are field22 and No is set as default.

The option will make the user choose if he wants to see a latest threads box or not.

I have tried the following:

<vb:if condition="$post['field22']=='No'">
code for showing the box here
<vb:elseif condition="$post['field22']=='Yes'" />

</vb:if>

This apparently does not work as it hides the box no matter what option is selected.

I would really appreciate if someone could tell me where I got it wrong, or if there is another way to do this. I have also tried switching No and Yes with the same result.

Thanks in advance :)

Badshah93
07-24-2011, 02:29 PM
try 0 in place of No and 1 in place of yes.

kh99
07-24-2011, 03:09 PM
What template did you add your code to?

archet1337
07-24-2011, 07:26 PM
try 0 in place of No and 1 in place of yes.

Tried that, but still have the same problem.

What template did you add your code to?

The code is added to a custom template made by the mod showing the latest threads on my forums.

The template is named "MARCO1 Latest Forum Threads"

The code is as follows:

<li class="forumbit_nopost L1" id="cat{vb:raw forum.forumid}">

<div class="tcatBar">
<div class="tcatLeft"><div class="tcatRight foruminfo L1 collapse">
<h2>
<span class="forumtitle">{vb:raw vboptions.MARCO1_latesttablename}</span>
</h2>

</div></div>
</div>
<!-- End Forum tcat Heading ForumThemes -->
<!-- Start Forum thead Heading ForumThemes -->
<div class="forumbitBody">
<div class="thead_bar">
<div class="theadrow table">
<div class="forumbit_nopost L1">

<!--ticker-->
<div id="ticker-wrapper" class="no-js">
<ul id="js-news" class="js-hidden">
<script type="text/javascript" src="{vb:raw vboptions.bburl}/external.php?&type=js"></script>
<script type="text/javascript">
<!--
for (var i = 0; i < threads.length; i++)
{
document.write('<li><b><a href="{vb:raw vboptions.bburl}/showthread.php?t=' + threads[i]['threadid'] + '">' + threads[i]['title'] + '</a></b>' + '&nbsp;&nbsp;&nbsp;' + '<span style="color: #323232;">Posted By:</span>'+ '&nbsp;' + threads[i]['poster'] + '</a>' + '</li>');
}
//-->
</script>
</ul>
</div>
<!--ticker-->
</div>
</div>


</div>

</div>

</div>
<div class="bottomBar"><div class="bottomBarLeft"><div class="bottomBarRight">&nbsp;</div></div></div>
</li>
Sorry for the messy code, haven't had time to clean it up yet :P

You can see the box in action underneath the navbar here http://www.radioctrl.com/forum.php

Would the conditionals work if this was added to the navbar template instead, or would that break the script?

kh99
07-24-2011, 08:01 PM
The code is added to a custom template made by the mod showing the latest threads on my forums.

The template is named "MARCO1 Latest Forum Threads"


I was asking because I was wondering if $post would be defined, but now that I read your description it sounds like you'd want to check the "viewing" user's setting and not a posting user. So I think what you'd want is:

<vb:if condition="$bbuserinfo['field22']=='No'">
code for showing the box here
</vb:if>


(there's no reason to have an 'else' unless you want to insert some alternative HTML).

archet1337
07-24-2011, 08:15 PM
Thanks for looking into this, kh99 :)

It's working perfectly now. $bbuserinfo did the trick!

Thanks a million!

Edit: Added the elseif conditional to make it show for guests as well. Good times!