1. 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?

Discussion in 'Styling and Customization Questions' started by Rob, Jun 25, 2015.

  1. Rob

    Rob Well-Known Member

    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.
  2. Martok

    Martok Well-Known Member

  3. Brogan

    Brogan XenForo Moderator Staff Member

    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.
  4. Martok

    Martok Well-Known Member

    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.
  5. Stuart Wright

    Stuart Wright Well-Known Member

    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?
  6. James

    James Well-Known Member

    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)?
  7. Stuart Wright

    Stuart Wright Well-Known Member

    If a thread has 4 replies then there will be 5 posts on the page. It's that number I need.
  8. Liam W

    Liam W Well-Known Member

    {xen:count $posts}
  9. Stuart Wright

    Stuart Wright Well-Known Member

    Thank you.
    That's always zero in the particular template I'm using it in, though. It's a template created by a custom addon so I will have to explore further.

Share This Page