vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Need help with elseif contitional for single-selection radio buttons (https://vborg.vbsupport.ru/showthread.php?t=267338)

archet1337 07-24-2011 01:14 PM

Need help with elseif contitional for single-selection radio buttons
 
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:

Code:

<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 01:29 PM

try 0 in place of No and 1 in place of yes.

kh99 07-24-2011 02:09 PM

What template did you add your code to?

archet1337 07-24-2011 06:26 PM

Quote:

Originally Posted by Sherif (Post 2224337)
try 0 in place of No and 1 in place of yes.

Tried that, but still have the same problem.

Quote:

Originally Posted by kh99 (Post 2224354)
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:

Code:

<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 07:01 PM

Quote:

Originally Posted by archet1337 (Post 2224453)
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:

HTML Code:

<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 07: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!


All times are GMT. The time now is 11:30 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02590 seconds
  • Memory Usage 1,730KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete