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

access postsPerPage and page in "post" or "message" template

Discussion in 'XenForo Development Discussions' started by Kintaro, Aug 1, 2014.

  1. Kintaro

    Kintaro Well-Known Member

    Here it is a newbie question:

    I need to calculate inside message template the position of posts in relation to number of post per page and of course the page number.

    I need to do:
    position - (postPerPage*(page - 1))
    The question is:
    How can I access $thread.postsPerPage and $thread.page inside message template?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Posts per page is a global option and the values of global options are available... globally :p

    In a template, you can do:

    {$xenOptions.messagesPerPage}

    Bringing what you want to do together, this should work:

    Code:
    {xen:calc '{$message.position} - ({$xenOptions.messagesPerPage} * ({$page} - 1))'}
    Note: I have assumed {$message} but it may depend on what template that is used in. If $message doesn't work, try $post.
     
    Kintaro likes this.

Share This Page