Problem in Topics-per-page and pagination question
(5 posts)-
Hey _ck_!
- 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?
- how I can show an pagination information like this?
Showing post 1 to 10 of 30 | Pages: 1 2 3
Posted 1 year ago # - 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.
-
I don't know if you noticed, but here is the same: the first page shows 18 topics and the others 15...
Posted 1 year ago # -
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_linksandfunction paginate_linksto see how they work and use their filters.Posted 1 year ago # -
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 1 year ago # -
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 zeroJust 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 1 year ago #
Reply
You must log in to post.