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 10-02-2012, 06:15 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $forumid in conditional help

I've added some code to the end of my navbar template so that it would print out a phrase only for a few forums:
HTML Code:
<if condition="$forumid==16 || $forumid==45 || $forumid==46">
<phrase 1=$LMR_date>$vbphrase[tug_lmr_date]</phrase><br />
</if>
This works great for the three forums specified, and does not execute for other forums -- most of the time.

My problem is that this conditional is sometimes triggering when the forum displays search results. It could be Today's Posts, it could be a search for posts by a given user, etc.

I added some code before the conditional to always display the forum number in white (nearly invisible but can select with cursor to read it). This confirms that sometimes (not always) the forumid comes back as one of the three forum numbers when doing a search, and when it does the conditional kicks in.

It does NOT seem to be tied to what forum the user is in when doing the search. You could be in forum 5, say, hit Today's Posts, and when the search results display, my "hidden" text may show that he's in forum 45, and the conditional triggers.

It may be tied to the search results themselves somehow, but I have not been able to discern a pattern. It doesn't seem to be tied to the forum of the first search return found, nor the last one on the page, nor the last one on the last page.

Can anybody tell me what is going on, and more importantly, how can I prevent it?
Reply With Quote
  #2  
Old 10-02-2012, 06:30 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you only want it to trigger on a forumdisplay page, then the first part of the condition should be THIS_SCRIPT == 'forumdisplay' AND (the forum condition here).
Reply With Quote
  #3  
Old 10-02-2012, 07:04 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Probably better to do it like this:
HTML Code:
<if condition="THIS_SCRIPT == 'forumdisplay' AND in_array($forum['forumid'], array(16,45,46))">
<phrase 1=$LMR_date>$vbphrase[tug_lmr_date]</phrase><br />
</if>
or
HTML Code:
<if condition="THIS_SCRIPT == 'forumdisplay' AND in_array($forumid, array(16,45,46))">
<phrase 1=$LMR_date>$vbphrase[tug_lmr_date]</phrase><br />
</if>
Reply With Quote
  #4  
Old 10-02-2012, 07:37 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, we're getting warmer.

I need it to show for any activity within those forums:
forum display
thread display
entering or editing a message.
Reply With Quote
  #5  
Old 10-02-2012, 07:41 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In that case you'l have to edit it and change this bit
HTML Code:
<if condition="THIS_SCRIPT == 'forumdisplay'
for
HTML Code:
<if condition="in_array(THIS_SCRIPT, array('forumdisplay', 'showthread')
and extent the array of script names as needed.
Reply With Quote
Благодарность от:
Lynne
  #6  
Old 10-02-2012, 07:55 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again.
HTML Code:
<if condition="in_array($forumid, array(16,45,46))">
is working as it should. Will add the additional conditions as suggested and report back.

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

That did the trick.

What I ended up with:
HTML Code:
<if condition="in_array($forumid, array(16,45,46)) AND in_array(THIS_SCRIPT, array('forumdisplay', 'showthread', 'newthread', 'newreply'))">
<phrase 1=$LMR_date>$vbphrase[tug_lmr_date]</phrase><br />
</if>
If I find I missed any needed templates, I can always add them in.

I figured it would be best to test for forumid first, as that would give more rejections right away than testing for the script first. Is this proper thinking to minimize server load?

Sure does seem strange to get those spurious forum numbers returned by forumid, but what the heck, this makes it a non-issue.

Thanks again. I really appreciate those of you who give of your time to help out those of us with less programming knowledge.
Reply With Quote
  #7  
Old 10-02-2012, 10:27 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by makaiguy View Post
If I find I missed any needed templates, I can always add them in......
They're not templates you're checking for!, they're php scripts, so fo argument sake you couldn't add 'footer' to the condition because it's a template and doesn't call a php script
Reply With Quote
  #8  
Old 10-03-2012, 12:30 AM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the clarification. Much appreciated.
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 11:43 AM.


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.04247 seconds
  • Memory Usage 2,243KB
  • 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
  • (7)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete