vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Condition based on how many posts in showthread? (https://vborg.vbsupport.ru/showthread.php?t=203631)

punchbowl 01-30-2009 06:03 PM

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

Dismounted 01-31-2009 02:32 AM

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.

punchbowl 01-31-2009 11:17 AM

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

Dismounted 01-31-2009 11:42 AM

You may actually have to use [s]$foruminfo[/s] $threadinfo instead in the header template.

punchbowl 01-31-2009 12:02 PM

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

Dismounted 01-31-2009 12:10 PM

Sorry, I actually meant $threadinfo instead of $thread. :p

punchbowl 01-31-2009 12:13 PM

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? :D: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


All times are GMT. The time now is 02:19 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.01051 seconds
  • Memory Usage 1,726KB
  • 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
  • (6)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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