I created a block that displays 5 items that have been promoted to the frontpage. It offsets this list by 5 items. i.e. Let's say nodes 1-14 are promoted to the front page. It will display nodes 6-10.

I have added a pager to this and it shows 3 pages. When their should only be two. nodes 6-10 and then nodes 11-14.

If I remove the offset it still shows 3 pages and displays them correctly. nodes 1-5, nodes 6-10 and nodes 11-14.

So I think that the pager does not honor the offset supplied in the query. If you give me a hint on which file to look at I can look at submitting a patch.

CommentFileSizeAuthor
#3 pager.patch856 bytesredndahead

Comments

merlinofchaos’s picture

I believe line 658 of views.inc is what we need. Total rows isn't accounting for the offset and it probably should.

This line:

        $this->total_rows = db_result(db_query($count_query, $args));

Should probably be

        $this->total_rows = db_result(db_query($count_query, $args)) - $this->pager['offset'];

If you could test that this works, this could be an easy fix.

redndahead’s picture

hmm my line 658 has this:

$pager_total_items[$this->pager['element']] = $this->total_rows;

And through some testing I had did earlier I changed it to this:

$pager_total_items[$this->pager['element']] = $this->total_rows - $this->pager['offset'];

I was running into an ajax error: An error occurred at /views_cck/views/ajax

I tracked that down to include/ajax_view.js

If you comment out lines 91-110 everything works perfectly. I'm positive it's in the .ajax call, but I haven't had the time to look into what it is. Being my first time looking inside of views it would take me a while to figure that out. Hopefully you can come up with it before me.

redndahead’s picture

Version: 6.x-2.0-rc1 » 6.x-2.x-dev
StatusFileSize
new856 bytes

Here is a beginning patch file. Also moving version to dev since this patch is against head.

redndahead’s picture

Status: Active » Needs work

duh the patch needs work.

merlinofchaos’s picture

Status: Needs work » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.