• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Conditional to check number of posts on page?

Rob

Well-known member
#1
Hi, I want to show an advert after the first post on every page (X) of a thread... but only if there is more than one post to display.

I'm hoping there is a variable available to templates that will help me achieve this.

Thanks for your help.
 

Brogan

XenForo moderator
Staff member
#3
I don't think the reply count is mentioned in the guide, so use this:

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">

You may also want to add the conversation element to stop them being shown there.
 

Martok

Well-known member
#4
Heh I forgot I was using the code Brogan posted for adverts on my site, I thought I was using the code from point 17.
 

Stuart Wright

Well-known member
#5
To revive this thread (because it has the most relevant title) how to I get the variable for the number of posts on the current page?
 

James

Well-known member
#6
Unless I'm missing something will $xenOptions.messagesPerPage not show you that? Or are you suggesting if the posts per page is less than the maximum specified (i.e. first/last page)?
 

Stuart Wright

Well-known member
#7
Unless I'm missing something will $xenOptions.messagesPerPage not show you that? Or are you suggesting if the posts per page is less than the maximum specified (i.e. first/last page)?
If a thread has 4 replies then there will be 5 posts on the page. It's that number I need.