vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   $forumid in conditional help (https://vborg.vbsupport.ru/showthread.php?t=288568)

makaiguy 10-02-2012 06:15 PM

$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?

Lynne 10-02-2012 06:30 PM

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

Simon Lloyd 10-02-2012 07:04 PM

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>


makaiguy 10-02-2012 07:37 PM

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.

Simon Lloyd 10-02-2012 07:41 PM

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.

makaiguy 10-02-2012 07:55 PM

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.

Simon Lloyd 10-02-2012 10:27 PM

Quote:

Originally Posted by makaiguy (Post 2370288)
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 :)

makaiguy 10-03-2012 12:30 AM

Thanks for the clarification. Much appreciated.


All times are GMT. The time now is 11:48 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.01107 seconds
  • Memory Usage 1,736KB
  • 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
  • (7)bbcode_html_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete