Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 05-11-2013, 07:54 PM
ExcelFox ExcelFox is offline
 
Join Date: Apr 2011
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Use $foruminfo[forumid] In_Array in BBCode

I am trying to use the following conditional in the BBCode

<vb:if condition="in_array($foruminfo[forumid], array(1,2)) AND $bbuserinfo[userid]">

If works fine if the $bbuserinfo[userid] is used alone. However, I can't get the forumid bit to work. I have disabled post caching.

For some reason, $foruminfo[forumid] is returning 0. Well, to put it another way, in_array($foruminfo[forumid], array(0,1,2)) is true no matter which forum I am on, and in_array($foruminfo[forumid], array(1,2) is false, no matter which forum I am on. Any ideas how I can get this to work for forum ids, 1 and 2, and for all other forum ids, go to the else conditional?
Reply With Quote
  #2  
Old 05-11-2013, 08:27 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I could be wrong about everything here, but .............

I don't think you can use in_array() in a conditional, so try

Code:
<vb:if condition="($foruminfo[forumid]==1 OR $foruminfo[forumid]==2) AND $bbuserinfo[userid])>
I don't think any of the usual variables are available in bb code, but if $bbuserinfo is available maybe I'm wrong.

You might try
$vbulletin->foruminfo[forumid] instead of $foruminfo[forumid] and likewise $vbulletin->bbuserinfo[userid], and see if that helps.
Reply With Quote
  #3  
Old 05-11-2013, 08:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Or if those don't work, try $GLOBALS['forumid'].

I'm confused about the question because you normally can't use template tags in a bbcode, but it sounds like it's working in your case (otherwise you'd always see whatever is between the tags).
Reply With Quote
  #4  
Old 05-11-2013, 08:49 PM
ExcelFox ExcelFox is offline
 
Join Date: Apr 2011
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nerbert, thanks for your reply..

Yes, normally you won't have any of the usual variables in the bbcode. having said that, there is a mod available here somewhere that allows usage of those variables within the bbcode. Otherwise, I wouldn't have been able to use $bbuserinfo[userid] either. I'll give your suggestion a try.
Reply With Quote
  #5  
Old 05-11-2013, 08:51 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Or if those don't work, try $GLOBALS['forumid'].

I'm confused about the question because you normally can't use template tags in a bbcode, but it sounds like it's working in your case (otherwise you'd always see whatever is between the tags).
I'm experimenting around and it seems you CAN use $foruminfo in conditionals but things like {vb:raw bbuserinfo.userid} don't work
Reply With Quote
  #6  
Old 05-11-2013, 08:52 PM
ExcelFox ExcelFox is offline
 
Join Date: Apr 2011
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kevin, will try your code too. Again, to my point above, there's a mod available here somewhere that allows you to use template tags in a bbcode. I can't seem to find it now. So yeah, if you check my forum www.excelfox.com, you'll see that unless you are a registered user, you won't be able to see the contents of within the code tags. So yeah, it IS working with $bbuserinfo[userid], but not with the tag I mentioned in my original post.

--------------- Added [DATE]1368309819[/DATE] at [TIME]1368309819[/TIME] ---------------

Alright, GLOBALS has done the trick. foruminfo doesn't seem to work. It always returns zero! Thanks a lot Kevin. Thanks for nerbert also for looking at this. Cheers mates.
Reply With Quote
  #7  
Old 05-11-2013, 09:06 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sure $foruminfo[forumid] is available for conditionals

In my experiment <vb:if condition="$foruminfo[forumid]>0">yes</vb:if> returns "yes". I think you just have to work around not being able to use in_array().
Reply With Quote
  #8  
Old 05-11-2013, 09:12 PM
ExcelFox ExcelFox is offline
 
Join Date: Apr 2011
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Strange. Though I don't know how GLOBALS and foruminfo are different, I was also under the impression that foruminfo should work. For some reason, <vb:if condition="$foruminfo[forumid]>0">yes</vb:if> doesn't work for me!!

--------------- Added [DATE]1368310619[/DATE] at [TIME]1368310619[/TIME] ---------------

You sure you're testing it within the BBCODE? For the life of me, I cannot get $foruminfo[forumid] to work!!!
Reply With Quote
  #9  
Old 05-11-2013, 09:53 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is one of those questions that gets asked occasionally. Apparently $foruminfo[forumid] doesn't work everywhere, but $GLOBALS['forumid'] seems to do it. Also, you can't use any variables in a template that haven't been registered, so even if $foruminfo exists, it probably wouldn't work in your situation (I assume nerbert is testing using another template, which is why it works). $GLOBALS[] is a "superglobal" so it's available everywhere.

BTW, in_array() is allowed in a template conditional (according to the manual anyway).
Reply With Quote
  #10  
Old 05-11-2013, 10:34 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ExcelFox View Post
Strange. Though I don't know how GLOBALS and foruminfo are different, I was also under the impression that foruminfo should work. For some reason, <vb:if condition="$foruminfo[forumid]>0">yes</vb:if> doesn't work for me!!

--------------- Added [DATE]1368310619[/DATE] at [TIME]1368310619[/TIME] ---------------

You sure you're testing it within the BBCODE? For the life of me, I cannot get $foruminfo[forumid] to work!!!
This is the html I'm using for [experiment] kkk [/experiment]

Code:
<div>{param}<vb:if conditon="$foruminfo[forumid]>0"> yes</vb:if> $foruminfo[forumid]</div>
I get

kkk yes $foruminfo[forumid]

--------------- Added [DATE]1368315733[/DATE] at [TIME]1368315733[/TIME] ---------------

Quote:
Originally Posted by kh99 View Post
BTW, in_array() is allowed in a template conditional (according to the manual anyway).
Maybe it was vB3 that didn't allow that
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 08:45 PM.


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.06331 seconds
  • Memory Usage 2,242KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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