Skip to:
Content
Pages
Categories
Search
Top
Bottom

Check for topic pages > 1


  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    Any easy way to check if a topic has multiple pages? I’d like to wrap the pages in a div or UL but only if pages actually exist.

Viewing 5 replies - 1 through 5 (of 5 total)

  • chrishajer
    Participant

    @chrishajer

    Since this plugin does pagination, there are functions in it to figure out how many pages there are then add page links. I suspect if you looked at the functions you might be able to see how it was done by _ck_.

    http://bbpress.org/plugins/topic/front-page-topics/


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    That plugin uses the built in bbPress get_page_number_links API, which does not have a function to check for the availability of pages. It only echo’s the links if they are needed.


    _ck_
    Participant

    @_ck_

    To figure out pages is easy.

    You lookup how many posts are in the topic and then you divide by the page_topics setting which also happens to be the posts per page setting.

    something like:

    $pages=ceil($topic->topic_posts/bb_get_option('page_topics'));


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Perfect!

    …in theme/topics.php…

    <?php If (ceil($topic->topic_posts/bb_get_option('page_topics'))>1) { ?>
    <div class="topic-page">
    <?php topic_pages();?>
    </div>
    <?php } ?>


    Derek Herman
    Member

    @valendesigns

    Is there a version for the forums page?

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.