Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 01-30-2009, 06:03 PM
punchbowl punchbowl is offline
 
Join Date: Nov 2006
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Condition based on how many posts in showthread?

Ok detecting it's showthread is easy

Code:
<if condition="THIS_SCRIPT == 'showthread'">
but is there a way to tell how many posts are on the page?

e.g. If a thread has more than 10 posts would it be something like this?


Code:
<if condition="THIS_SCRIPT == 'showthread' AND $post['postcount']>10">do something</if>
or do I have to use this freaky bit of stuff below somehow if there?

Code:
$post['postcount'] % $vboptions['maxposts'] == x"
tia
Reply With Quote
  #2  
Old 01-31-2009, 02:32 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
<if condition="THIS_SCRIPT == 'showthread' AND $thread['replycount'] > 10">
If you're editing the showthread template, you don't need the first condition, it's a given that it is the showthread script.
Reply With Quote
  #3  
Old 01-31-2009, 11:17 AM
punchbowl punchbowl is offline
 
Join Date: Nov 2006
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fantastic thanks D! What I'm doing is adding another banner to the side column if there's a few replies to a thread so it's actually the header template that'll be edited. Lots of white space there at the moment.

Cheers
Reply With Quote
  #4  
Old 01-31-2009, 11:42 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You may actually have to use [s]$foruminfo[/s] $threadinfo instead in the header template.
Reply With Quote
  #5  
Old 01-31-2009, 12:02 PM
punchbowl punchbowl is offline
 
Join Date: Nov 2006
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah it doesn't seem to work here's what I have:

Code:
<if condition="$show['guest']">
<table width="$stylevar[outertablewidth]" border="0" cellpadding="0" cellspacing="0" align="center">
	<tr>

	<td width="140" valign="top" class="page" style="padding: $stylevar[cellpadding]px;"><if condition="THIS_SCRIPT == 'forumdisplay' AND $show['guest']">
<div align="center">AD HERE</div><br />
</if>
<div align="center">AD HERE</div>
<if condition="$show['guest'] AND THIS_SCRIPT == 'showthread' AND $thread['replycount'] > 5">this ad never shows</if>
	<td valign="top">
	</if>
<!-- content table -->
Another question are the $show['guest'] conditions in the second two conditions obsolete as they are wrapped in a $show['guest'] condition anyway?

I know I could be playing around with this but it's a live board and they'd go hysterical if I started playing around now.

Cheers
Reply With Quote
  #6  
Old 01-31-2009, 12:10 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I actually meant $threadinfo instead of $thread.
Reply With Quote
  #7  
Old 01-31-2009, 12:13 PM
punchbowl punchbowl is offline
 
Join Date: Nov 2006
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could've said $mumbojumbo for all the use it's doing me lol

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

Ok after a lot of googling (your name came up a lot D!) and cross posting over at vb.com, it seems that unfortunately the "header template is parsed early in the page execution, before that information is available"

Jake suggested coding something in php. Instead Im thinking of replacing the $header call in SHOWTHREAD with a custom template depending on how many posts on the page.

Something like:

Code:
<if condition="($post[postcount]-1) % $GLOBALS[perpage] == 0">
     <if condition="($GLOBALS[totalposts] - $post[postcount]) > 5">$longheader
     <else />$header
     </if>
</if>
What do you think?! Madness? :erm:

Actually I've decided just to add another banner regardless of how many replies so I'm not going to bother with any of the above.

Thanks for the help - I learnt a bit anyway
Reply With Quote
Reply

Thread Tools
Display Modes

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 02:51 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.03995 seconds
  • Memory Usage 2,207KB
  • Queries Executed 13 (?)
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
  • (6)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete