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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2010, 12:16 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Forum if condition not working

Not sure what is going on but my if condition is not working. Not sure why but it is getting annoying.

$foruminfo['forumid'] works for showing when you click on the category itself but not when your viewing threads inside a forum.

HTML Code:
<if condition="in_array($forum['forumid'], array($vboptions['pl9_qloc']))">
$vboptions['pl9_qloc'] is a line of forum id's that are inserted once selected from the settings.

Any help much appreciated.

Thanks
Steve

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

Well a response was here, got an email so here is my reply.

As I didn't give the template I'm trying to use this in, I have added this:
Code:
navbar
If anyone has a suggestion to pull all forum id's and match them in an if condition array for this to display on selected forums then please do post it.

Thanks
Reply With Quote
  #2  
Old 01-05-2010, 02:39 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you look in the includes/functions.php file where the navbar is rendered, you'll see that $forum is not registered for use in that template. However, $foruminfo is registered for use, so try using that variable instead.
Reply With Quote
  #3  
Old 01-05-2010, 02:47 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I have it in the conditional already, let me post the full conditional.

HTML Code:
<if condition="in_array($foruminfo['forumid'], array($vboptions['pl9_qloc'])) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], array($vboptions['pl9_qloc']))">
<if condition="$vboptions['pl9_quote_display'] == 'table'">
$table
</if>
<if condition="$vboptions['pl9_quote_display'] == 'styled_table'">
$stable
</if>
<if condition="$vboptions['pl9_quote_display'] == 'normal_quote'">
$normal
</if>
<if condition="$vboptions['pl9_quote_display'] == 'styled_quote'">
$snormal
</if>
</if>
As you can see, the $foruminfo is there and works but only when viewing categories, here take a look at the link:
Category view with forums

Now click into one of those forums and it goes away.

EDIT: $vboptions[pl9_qloc] has all forums selected so all forum id's are in the settings row.
Reply With Quote
  #4  
Old 01-05-2010, 03:12 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh yikes, and I'm mixed up between vb4 and vb3, sorry about the stuff regarding registering!

You said that what I'm looking for is in the navbar, but I don't see anything different in the navbar when I click on one of the forums from the page you link to. What should I be looking for exactly?

Another thing..... when I've had a option field where I input a row of forumids... x,y,z and then I wanted to use them like you are (if in_array etc...), I've had to first explode it in a plugin...
ie. I have some forums set in option "verify_forums" (ie. 12,13,14)
In my plugin, I have
PHP Code:
$verifyforums explode(","$vbulletin->options[verify_forums]); 
Then in my template, I used:
HTML Code:
in_array($threadinfo[forumid], $verifyforums)
Reply With Quote
  #5  
Old 01-05-2010, 03:16 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh yeah sorry, the quote box goes away. Its above the navbar but I forgot to allow guests to see it. Let me change that, just keep refreshing on that first link and you will see it appear.

Good point on the explode, I will give that a try.

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

Ok you as a guest can now see the quote box. I'm such an idiot for not remembering to give perms to guests.

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

Ok did the explode function and changed the $foruminfo to reflect $pl9_qloc in the array but with $foruminfo['forumid'] it didn't show on any forum page.
Reply With Quote
  #6  
Old 01-05-2010, 03:23 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I see it now. It seems the only forumid it is currently working in is forumid 1. I would try the explode thing cuz I'm pretty sure that is it. The text field is simply a string as an option, so you need to turn it into an array before you can do your in_array condition.
Reply With Quote
  #7  
Old 01-05-2010, 03:27 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did the explode, here is what I have in the global_start plugin:

PHP Code:
$pl9_quoteloc explode(","$vbulletin->options['pl9_qloc']);

$quote_sql $db->query_read("SELECT * FROM " TABLE_PREFIX "bfc_quotes WHERE unapproved = 0 ORDER BY RAND() LIMIT 1");
while(
$quotes $db->fetch_array($quote_sql))
{
$uname $quotes['username'];
$quote_text $quotes['quote'];
eval(
'$table = "' fetch_template('bfc_quote_table') . '";');
eval(
'$stable = "' fetch_template('bfc_quote_stable') . '";');
eval(
'$normal = "' fetch_template('bfc_quote_normal') . '";');
eval(
'$snormal = "' fetch_template('bfc_quote_snormal') . '";');
}
eval(
'$quote = "' fetch_template('bfc_quote') . '";'); 
EDIT: Even with the change nothing plus the forum with the id of 1 it goes away on as well.
Reply With Quote
  #8  
Old 01-05-2010, 03:44 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And your condition is now like this ?
HTML Code:
<if condition="in_array($foruminfo['forumid'], $pl9_quoteloc) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], $pl9_quoteloc)">
If that isn't working, I'd start spitting stuff out in the template like $pl9_quoteloc and $vboptions['pl9_qloc'] to see exactly what it is getting.


Also, it looks like in your query, you are only pulling one row. You could just use query_first instead and then you don't have to do the fetch_array stuff:
PHP Code:
$quotes $db->query_first("SELECT * FROM " TABLE_PREFIX "bfc_quotes WHERE unapproved = 0 ORDER BY RAND() LIMIT 1");

$uname $quotes['username'];
$quote_text $quotes['quote'];
eval(
'$table = "' fetch_template('bfc_quote_table') . '";');
eval(
'$stable = "' fetch_template('bfc_quote_stable') . '";');
eval(
'$normal = "' fetch_template('bfc_quote_normal') . '";');
eval(
'$snormal = "' fetch_template('bfc_quote_snormal') . '";'); 
No biggie. What you wrote will work also, but query_first is also nice cuz it's easy.
Reply With Quote
  #9  
Old 01-05-2010, 03:50 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh no, the forumid stuff has nothing to do with the quotes in the database, that is separate. Basically I am just trying to get the if condition to work so it will display the quote box on the forumdisplay page that I choose.

I just changed my if condition to what you suggested as I still had:
HTML Code:
<if condition="in_array($foruminfo['forumid'], array($pl9_quoteloc)) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], $pl9_quoteloc)">
Notice the array() part. But when I remove that part, I get the following:

The following error occurred when attempting to evaluate this template:

Code:
Warning: in_array() [function.in-array]: Wrong datatype for second argument in [path]/includes/adminfunctions_template.php(3950) : eval()'d code on line 1

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
If I continue anyway without going back to the template, the quote box displays flawlessly, any reason why that error would come up when the if condition the way you suggested works flawlessly?
Reply With Quote
  #10  
Old 01-05-2010, 01:48 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, this is odd because it really is almost exactly the type of condition I use in a mod of mine. (Sorry I took off, sleep was calling.)

Check your options for pl9_qloc - is the data validation type set to Free ?

This is exactly my code in my plugin:
PHP Code:
$verifyforums explode(","$vbulletin->options['verify_forums']);
eval(
'$template_hook[showthread_verify_thread] .= " ' fetch_template('added_verify_threads') . '";'); 
And in my template:
HTML Code:
<if condition="is_member_of($vbulletin->userinfo,array(5,6)) AND in_array($threadinfo['forumid'], $verifyforums)">
That looks very much like exactly what you have:
PHP Code:
$pl9_quoteloc explode(","$vbulletin->options['pl9_qloc']);
...
eval(
'$quote = "' fetch_template('bfc_quote') . '";'); 
and then
HTML Code:
<if condition="in_array($foruminfo['forumid'], $pl9_quoteloc) OR THIS_SCRIPT == 'index' OR in_array($forum['forumid'], $pl9_quoteloc)">
Only other thing I can think of is to add something before your explode statement to define the variable as an array:
PHP Code:
$pl9_quoteloc = array(); 
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 10:17 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.05820 seconds
  • Memory Usage 2,289KB
  • 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
  • (7)bbcode_html
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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