Hi,

I have a module that pulls out student details from database and displays it on the page. Search results are usually multiple pages and are displayed 10 per page with links to the next page and previous page etc. (something like the google page number links on a search results page).

now, if i am on, say, page 3 of search results and make any changes to an entry and hit submit, it takes me back to the default page of search results i.e. page 0 and not page 3 where i previously was. the fix to this would be to return the current page number at the end of the submit button. However, this is where i run into problems...

1) when i goto the module page, the URL is:

http://abc.com/my_students

2) when i am on page 3 of results, the URL is:

http://abc.com/my_students?page=3&status=active

3) when i try returning a URL to take me back to page 3 after i submit, it says page cannot found and URL is:

http://abc.com/my_students%3Fpage%3D3%2526status%3Dactive

so it is interpreting the ?,= and & signs to %3F, %3D and %2526 for some reason ..

the return statement in my code looks like:

return 'my_students?page='.($form_values['currentpagenum']).'&status=active';

i tried using:

return 'my_students\?page\='.($form_values['currentpagenum']).'\&status\=active';

but it didn't make a difference.

Can anyone help me rectify this ????

Thanks a lot ..

Comments

mooffie’s picture

return 'my_students?page=

This destination is handed to drupal_goto().

Since drupal_goto() (actually url(), which is called by it) sees no 'http://' in this string, it assumes it is a Drupal path, not a URL, and therefore it escapes the characters in it. It's this escaping that ruins your plan.

So return an absolute URL:

return url('my_students', 'page=...', NULL, TRUE);

(Or do return array('my_students', 'page=...'); it's equivalent.)

(BTW, in D6 the second parameter, the $query, can be an associative array.)