Search

bbPress Showcase » Plugins by _ck_

  1. tikitakfire
    tikitakfire

    member
    Joined: May '08
    Posts: 12

    offline

    Hey _ck_!

    1. I using Topics-per-page with 5 posts in the front-page to test and, on the first page, the plugin displays 7 topics and in the following pages, shows 5.
      If I set 10 topics the plugin show 12 on the first page and 10 on the others, etc...

      How I can fix them?

    2. how I can show an pagination information like this?
      Showing post 1 to 10 of 30 | Pages: 1 2 3
    Posted 4 years ago #
  2. tikitakfire
    tikitakfire

    member
    Joined: May '08
    Posts: 12

    offline

    I don't know if you noticed, but here is the same: the first page shows 18 topics and the others 15...

    Posted 4 years ago #
  3. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 911

    offline

    Yes, bbPress has a minor flaw in that super-stickies override any per-page count and will be added to the total. So even though the per-page is set to 15, the first page has 3 super-stickies so there are 18 total.

    You can show pagination info by using the global $page; that bbPress uses internally to keep track of what page it's on but getting the total count is a little trickier.

    You'll have to study the function get_page_number_links and function paginate_links to see how they work and use their filters.

    Posted 4 years ago #
  4. tikitakfire
    tikitakfire

    member
    Joined: May '08
    Posts: 12

    offline

    Look, I make this function:

    function pagination_info() {
    	global $page, $topics, $super_stickies, $topics_per_page;
    
    	if (empty($forums)) {
    		$forums = get_forums();
    	}
    
    	foreach ($forums as  $forum) {
    		$info['total_topics'] += $forum->topics;
    	}
    
    	$info['current_topics'] = count($topics) + count($super_stickies);
    	$info['must_be'] = (($page - 1) * $topics_per_page['front-page']);
    	$info['from_topic'] = ($info['must_be'] + 1);
    	$info['to_topic'] = ($info['must_be'] + $info['current_topics']);
    
    	return $info;
    }

    and I set 5 topics in the front page.

    Now, if I have 10 topics and 1 is super sticky, in the first page returns from_topic 1 to_topic 6 (it's ok by the problem that you told me) and in the second page this returns from_topic 6 to_topic 9 when it should return from_topic 7 to_topic 10...

    Can give me some help to fix them?

    Posted 4 years ago #
  5. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 911

    offline

    The count for super_stickies is only done on page 1
    bbPress doesn't look them up if page>1 so count will always be zero

    Just don't try to include the stickies in the count, stickies are special.

    Also, bbPress might already know how many topics are in the total, I am uncertain what the variable name is for regular topic lists but in views the global is $view_count - you'd have to dig through the code to see what the variable is for regular topic lists.

    Since the front page doesn't normally paginate, study forum pages instead.

    This is the magic line where internally it knows how many topics there are, I just don't know the external variable name:

    $this->found_rows = bb_count_last_query( $this->request );

    Posted 4 years ago #

RSS feed for this topic

Post a reply to “Problem in Topics-per-page and pagination question”

You must log in to post.

keep _ck_ coding >> donate $5 <<     Theme Switcher:
44 users online from in the past 30 minutes. 7 bots 37 guests
3,292 views today 8,003 yesterday 89,978 peak. Most at once 44 today 75 yesterday 539 peak. Visited today: devinmarchan, hollylinney, bbdan, _ck_
2,432 posts in 416 topics over 79 months by 446 of 2,524 members. Latest: nafiz2333, devinmarchan, hollylinney