I'm working on developing a repository plug-in for Moodle 2.x and trying to figure out how to manage displaying and paging search results.
Here is the workflow at a high - mid level...
- A user click on the search link at the top of the file picker.
- Enters a search term
- The search term returns many results
-- In the search(), you setup your return structure and page data (page, pages, total, perpage)
-- The function returns with more than 1 page of data
This is where I'm puzzled... the user clicks on the page 2 link in the file picker. The plug-in search() function is called again, however the original search term is not passed as an argument. If search results can be paged, how do we figure out what the original search term is when the user click on one of the page links?
Also, the search form that I created has multiple search criteria in addition to the default keyword search. So it's important that I can keep track of the search options the user has selected when flipping through pages.
One way around this it to store the search term in the user's session variable. However I'm wondering if there is a 'best practice' way?