News:

Wondering if this will always be free?  See why free is better.

Main Menu

How to know total number of post in a topic

Started by olufemo, January 18, 2012, 07:28:36 PM

Previous topic - Next topic

olufemo

Before displaying message/post in a topic, pls is there a way the total number of posts in that topic can be determined

Arantor

Sure it's possible. But depending on what you're trying to do will reflect in how best to go about doing it.

olufemo

wish know the total number of posts in topic as integer (e.g 2 or 3 ..) after getting this I know how to use for further processing

Arantor

What further processing?

There are two different ways to get it, depending on what you're trying to do, one may be more efficient and better suited to you than the other.

olufemo

wish to post ads after x-1 post, if x >2, 
x = total posts in topic

Quote from: arrowtotheknee on January 18, 2012, 08:43:10 PM
What further processing?

Pls post the two different ways
Quote from: arrowtotheknee on January 18, 2012, 08:43:10 PM
There are two different ways to get it, depending on what you're trying to do, one may be more efficient and better suited to you than the other.

Mick.

I think this is what you're looking for....
', comma_format($board['posts']), ' ', $board['is_redirect'] ? $txt['redirects'] : $txt['posts'], '

Arantor

$board won't help you at all since you're not interested in the number of posts in the board, just in the topic. As it stands, you're not really interested in either of the figures I had in mind since they're nothing to do with what you want.

Bear in mind a topic can read multiple pages, what you're asking for is how to put an ad before the last post in the topic - regardless of how many pages it will run to. Whereas what I think you're wanting is how to put an ad before the last post on a page, as long as there's at least two posts.

Am I right? If so, I'll find you the right code.

(Now you understand why I wasn't going to give you any code just yet. Both the things I would have given you would have given you what you asked for but it wouldn't have been what you wanted.)

olufemo

Thanks for your effort. It keeps returning 0 value, seems not working.  Pls check

Quote from: bluedevil on January 19, 2012, 03:51:53 PM
I think this is what you're looking for....
', comma_format($board['posts']), ' ', $board['is_redirect'] ? $txt['redirects'] : $txt['posts'], '

Advertisement: