when i use a php-filter-handler it is impossible the number of items to display. The view keeps displaying all items that match the filter.

CommentFileSizeAuthor
#2 views_php_limit.patch1.1 KBamclin

Comments

amclin’s picture

This is true when using PHP Sort on PHP fields as well. Turning on a pager lets you limit the results per page, but setting a maximum number of results doesn't work.

amclin’s picture

Component: Filter Handler » Code
StatusFileSize
new1.1 KB

The problem is because for Views 2, this module disables the limit so that it can properly allow for sorting and filtering. When done, it should reapply the limit. This isn't an issue with paginated results because they are always unlimited, but for a fixed set of results, this plugin breaks critical functionality.

Here is a patch that solves this issue by trimming the result set if no pager is in use, and a limit for results was provided.

gertieiv’s picture

tnx, works fine

gertieiv’s picture

Status: Active » Fixed
amclin’s picture

Status: Fixed » Needs review

gertieiv, Status "Fixed" should only be used once the patch is actually committed.

Nick Robillard’s picture

Status: Needs review » Needs work

Interesting. I'm having this exact problem but with views 3. In my view configs I have limit set to 1 with no pager.

I removed the version check from the patch and it works for me now.

mattcasey’s picture

#2 also works for me, using Views 3 and removing some conditional code for Views 2

harysh’s picture

Thanks a lot for the patch, it worked me for Views 2. One more suggestion i would like to make to add offset value too in the function slice().

        if($this->view->pager['offset'])
 	   $offset = $this->view->pager['offset'];
	  else
	   $offset = 0;
       	$this->view->result = array_slice($this->view->result, $offset, $limit);

Hope this will help someone.

liam morland’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

If this applies to a later version, please re-open and update the version.