vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Forumhome Forumbit HELP! (https://vborg.vbsupport.ru/showthread.php?t=68172)

Michael Morris 08-10-2004 12:15 AM

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.

Modin 08-10-2004 12:27 AM

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.


Michael Morris 08-10-2004 01:18 PM

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?

CarCdr 08-10-2004 01:36 PM

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".

Michael Morris 08-10-2004 04:18 PM

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).

Modin 08-10-2004 04:20 PM

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.

AN-net 08-10-2004 05:16 PM

it could be because that template is used in a file that does not use those variables;)

Michael Morris 08-10-2004 07:58 PM

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.

Modin 08-11-2004 04:24 PM

^^ 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;

Michael Morris 08-11-2004 06:59 PM

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.


All times are GMT. The time now is 06:23 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.01127 seconds
  • Memory Usage 1,740KB
  • 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
  • (5)bbcode_code_printable
  • (1)bbcode_html_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete