Limiting search result pages

You have a suggestion for a future version of phpMyFAQ? Then post it here!

Moderator: Thorsten

Post Reply
dajoker
Posts: 59
Joined: Sat Jan 30, 2010 1:01 am

Limiting search result pages

Post by dajoker »

This may not be a change everybody wants, but considering how most people search anymore (spoiled by Google for better or worse) I think it's reasonable. In my setup I return too many pages to be attractive or worthwhile. It'd be best, in my opinion, if I could only show ten pages of result links at a time but since I do not really expect more than one user per year to actually go past some configured number of pages EVER this is something I'm proposing adding... an optional limit to the number of results returned.

Add config value to table: INSERT INTO faqconfig (config_name, config_value) VALUES ('records.maxSearchResultPages', '10');

Use the config value within ./phpmyfaq/inc/functions.php as shown below:
<quote file='./phpmyfaq/inc/functions.php' version='2.6.5'>
567a568
< $pages = ceil($num / $confPerPage);
---
> //Adding a line to limit the number of returned pages when using the web interface based on the 'records.maxSearchResultPages' config value.
> if ((intval($faqconfig->get('records.maxSearchResultPages')) > 0) && ($num / $confPerPage > $faqconfig->get('records.maxSearchResultPages'))) { $num = $confPerPage * $faqconfig->get('records.maxSearchResultPages'); }
> $pages = ceil($num / $confPerPage);
</quote>

I did not implement this in the api.php file, though it could probably go there too, since I figured users of the API may not have page issues as much as browsers do. One of my problems is the page options running off the page (right-hand side), but fixing that just makes a huge block of six-thousand pages to scroll through (by default) for some queries; neither option is great and this is a simple workaround. For backward compatibility this value could default to zero to basically invalidate the change.
Post Reply