Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 07-24-2011, 02:14 PM
archet1337's Avatar
archet1337 archet1337 is offline
 
Join Date: Sep 2009
Location: Norway
Posts: 251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 07-24-2011, 02:29 PM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try 0 in place of No and 1 in place of yes.
Reply With Quote
  #3  
Old 07-24-2011, 03:09 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What template did you add your code to?
Reply With Quote
  #4  
Old 07-24-2011, 07:26 PM
archet1337's Avatar
archet1337 archet1337 is offline
 
Join Date: Sep 2009
Location: Norway
Posts: 251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Sherif View Post
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 View Post
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?
Reply With Quote
  #5  
Old 07-24-2011, 08:01 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by archet1337 View Post
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).
Reply With Quote
  #6  
Old 07-24-2011, 08:15 PM
archet1337's Avatar
archet1337 archet1337 is offline
 
Join Date: Sep 2009
Location: Norway
Posts: 251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03689 seconds
  • Memory Usage 2,212KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete