The pagination for searching doesn't work right

Project:ProjectPier
Version:0.8.5.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Alex.
Status:patch - ready to commit
Description

HI,I have used the projectpier for 3 weeks,and I find it is very good.But I am sorry to say I found one bug:
when I used the search fuction to find what I wanted,if the counts was needed to be shown via pagination,and the pages were 2 or 3 or 4 or more.I can't see the second or the next page,that is to say,the pagination works not correctly.
Thank you for your reading.I hope you can solve it quickly.

See more details posted here http://projectpier.org/node/1039

Keep this as the main thread.

Status:open - needs more info» new

I wrote these steps to explain this bug:
The steps:

1,use the search bar to find somethings

2, The page will go to the "search results" page.( Dashboard » test » Search results )
and the code file is search.php.

3, The results' pagination function is not right. Such as:there are 3 pages,but I click the 2nd or the 3rd page, the results that should be in the 2nd or 3rd page can't be displayed.The results is as the same as in the first page.

Thanks!

Component:User interface» Code

I think the reason for this bug is the file ("advanced_pagination.php").I checked this file.Maybe there is something wrong,but to now,I can't find any way to solve it.

Hi,how is the problem now?

Assigned to:Visitor» Alex.
Status:new» open - assigned

I've found the source of this issue and I'll be submitting a patch shortly.

Version:0.8.0.2» 0.8.5.x-dev
Status:open - assigned» patch - ready to commit

Patch attached.

For those of you who just can't wait (:P), then open
application/models/projects/Project.class.php

Find (line 1187)

    /**
    * Return search URL
    *
    * @param string $search_for
    * @param integer $page
    * @return string
    */
    function getSearchUrl($search_for = null, $page = null) {
      if (trim($search_for) <> '') {
        $params = array(
          'active_project' => $this->getId(),
          'search_for' => $search_for,
          'page' => (integer) $page > 0 ? (integer) $page : 1
        ); // array
        return get_url('project', 'search', $params);
      } else {
        return ROOT_URL . '/index.php';
      } // if
    } // getSearchUrl

and replace with:

    /**
    * Return search URL
    *
    * @param string $search_for
    * @param string placeholder for search page
    * @return string
    */
    function getSearchUrl($search_for = null, $page = '#PAGE#') {
      if (trim($search_for) <> '') {
        $params = array(
          'active_project' => $this->getId(),
          'search_for' => $search_for,
          'page' =>  $page,
        ); // array
        return get_url('project', 'search', $params);
      } else {
        return ROOT_URL . '/index.php';
      } // if
    } // getSearchUrl

For the coders out there, the function was converting the placeholder to an integer (1).

AttachmentSize
search_200806191645_r161.patch917 bytes

Thanks Alex!
The parameter 'page' in the URL is right now!But I am sorry to say the pagination is not right!I click the 2nd or more,and it is as the same as the first page.

This patch should fix both issues.

AttachmentSize
search_200806201158_r161.patch1.9 KB

This patch should work

AttachmentSize
search_fix_2008-09-06_17-33_r169.patch1.9 KB