Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2004, 12:15 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Forumhome Forumbit HELP!

Hey. I'm having trouble getting a template mod to work with the 4 forumhome forumbit templates. Basically, I want to give my users the ability to turn off forum icons in my forum listings to save bandwidth. Unfortunately the system always evaluates the following to false.

HTML Code:
<if condition="$forum['icon'] AND $extrauseroptions['display_forumicon']">
Display the forum icon code goes here.
Now, forum icon is defined by the database through a hack. It works fine BY ITSELF. The $extrauseroptions array is defined in the phpinclude_start template.

Now I've used this kind of conditional in $threadbit, $header, $navbar, $FORUMHOME with NO PROBLEMS WHATSOEVER!!! Why is the system failing to recognize this variable in these four templates.

NOTE: I *suspect* it has to do with variable scope, but if that's the case WHY ONLY HERE?? Why haven't I seen this occur in $threadbit, postbit, etc??

-- Getting incredibly fustrated here, Mike.
Reply With Quote
  #2  
Old 08-10-2004, 12:27 AM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try removing the single quotes, I don't believe you can have them in a conditional

Code:
<if condition="$forum[icon] AND $extrauseroptions[display_forumicon]">
Display the forum icon code goes here.
Reply With Quote
  #3  
Old 08-10-2004, 01:18 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Modin
try removing the single quotes, I don't believe you can have them in a conditional

Code:
<if condition="$forum[icon] AND $extrauseroptions[display_forumicon]">
Display the forum icon code goes here.
Wrong answer - it won't compile at all if you remove them.

The syntax is correct - it works in EVERY TEMPLATE EXCEPT the four forumhome_forumbits. WHY?
Reply With Quote
  #4  
Old 08-10-2004, 01:36 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I presume you have verified the values by outputting them to the page. For instance, you say that "$forum['icon']" works, so I presume you sent it to the page to verify its contents for each forum. Did you do the same for "$extrauseroptions" to verify that it contains nothing?

Post the code that sets "$extrauseroptions".
Reply With Quote
  #5  
Old 08-10-2004, 04:18 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CarCdr
I presume you have verified the values by outputting them to the page. For instance, you say that "$forum['icon']" works, so I presume you sent it to the page to verify its contents for each forum. Did you do the same for "$extrauseroptions" to verify that it contains nothing?

Post the code that sets "$extrauseroptions".
$forum['icon'] works by itself. That is

<if condition="$forum['icon']">code</if>

works without a hitch. It's output can be seen in the images it fetches.

I've run tests where I simply typed

$extrauseroptions['display_forumicon'] = true;

And it didn't work. I've echo'ed the variable at the end of the phpinclude_end template and it's came back as 1, which is normal for a boolean.

The only thing I can think of is that it's simply not being *seen* by the section of code that parses those templates and I need to make the variable global in scope somehow. Short of adding it's value to $GLOBALS I don't know how (and I've never had to worry about variable scope before with vbulletin so I'm not too sure even then).
Reply With Quote
  #6  
Old 08-10-2004, 04:20 PM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this
Code:
<if condition="$forum[icon] == 1 AND $extrauseroptions[display_forumicon] == 1">
Display the forum icon code goes here.
I've used that a 1000 times (without the quotes too) and it's always worked...as long as you set $extrauseroptions before the template is called.

It would only be a scope problem if $extrauseroptions was set in a function and wasn't returned, nor set to global within the function.
Reply With Quote
  #7  
Old 08-10-2004, 05:16 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it could be because that template is used in a file that does not use those variables
Reply With Quote
  #8  
Old 08-10-2004, 07:58 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, in PHP functions can't see variables outside themselves unless they are declared as global. So if the forumbit templates are evalutated by a function...

I tried directly linking to $bbuserinfo, no go there either, and as far as I know that's a vbulletin global... So I give up.

And let me repeat for those who didn't read it the first time: $forum['info'] works by itself. Therefore the problem MUST BE in the second variable. I've altered the code to print the value of the variable - and sure enough it's null in those templates only even when it has a value elsewhere.
Reply With Quote
  #9  
Old 08-11-2004, 04:24 PM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ that's exactly what I said

try this, open up functions_forumlist.php and find
Code:
function construct_forum_bit($parentid, $depth = 0, $subsonly = 0)
{
after it add
Code:
global $extrauseroptions;
Reply With Quote
  #10  
Old 08-11-2004, 06:59 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I'll try that tomorrow. Right now my setup is under executive review - I dare not hack something and cause a parse error. Thx.
Reply With Quote
Reply


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 09:57 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.05402 seconds
  • Memory Usage 2,254KB
  • 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
  • (5)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete