Forums / Developer / Search/Advanced search problems with a user defined page limit

Search/Advanced search problems with a user defined page limit

Author Message

Paul Forsyth

Saturday 17 May 2003 12:11:12 pm

Kernel/content/search.php and kernel/content/advancedsearch.php have a hard coded variable named $pageLimit which determines the number of search results displayed before offsets are used and split over pages.

Since there is already code within these files to use a varariable named 'SearchLimit' it seems sensible to allow the user to define this limit. For example i have this code now inside these files:

$pageLimit = 10;

if ( $http->hasVariable( "SearchLimit" ) and
$http->variable( "SearchLimit" ) != -1 )
{
$pageLimit = $http->variable( "SearchLimit" );
}

I've just published a bug regarding searching which is related to this, although not mentioned in the bug report:

http://ez.no/developer/ez_publish_3/bug_reports/advanced_searching_with_content_class_id_and_offsets_broken

If I wish to limit the search using SearchContentClassID with smaller page limit than 10, and there are more articles found with the search than the page limit it will use offsets to show the remainder.

However, because of this bug other results from other classes will be included in the result which takes it over page limit. This seems to be at the root of this filed bug:

http://ez.no/developer/ez_publish_3/bug_reports/narrowed_search

This seems evident on the ez site and the svn stable 2450 stable release i am using.

Any chance of a fix on this?

Paul

Ekkehard Dörre

Tuesday 20 May 2003 4:32:54 am

narrowed_search working now

http://ez.no/developer/ez_publish_3/contributions/advancedsearchtpl

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Paul Forsyth

Monday 26 May 2003 3:28:39 am

thanks ekke!

I had just started to notice that i needed to add more info to the the form.

btw, in your code you have:

'SearchContentClassAttributeID=',$search_contentclass_id

but maybe it should be:

'SearchContentClassID=',$search_contentclass_id

as attribute is another field altogether.

paul

pps, adding:

'&SearchLimit=',$page_limit

along with the code modification to the advancedsearch.php i gave in my first post seems to work well.

Jan Borsodi

Monday 25 August 2003 4:08:20 am

With 3.2 you can search using a template fetch operator, there you can add limits, offsets and any other search parameter found in advancedsearch.php.

http://ez.no/developer/ez_publish_3/documentation/customization/components/search/search_operator

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Paul Forsyth

Wednesday 27 August 2003 3:04:35 am

Thanks Jan,

With the new way of searching does this mean the old way through a submit will be depracted in future releases? Are ez recommending using the new fetch method?

I notice that bug i filed is marked as fixed but it is not. While the new fetch method may work the other method of using page limit to control the number of results returned is still the same. You can set the page limit in your template file but it is not read by the advancedsearch.php script. The bug fix remains the same: stick in the code to recognise the post variable.

This is with ez3.2 beta 1.

paul

Jan Borsodi

Thursday 28 August 2003 4:16:50 am

> With the new way of searching does this mean the old way through a submit will be depracted in future releases? Are ez recommending using the new fetch method?

You will have more flexibility with the new search operator, it also means you can use it in other templates for instance to replace a normal list fetch.

> You can set the page limit in your template file but it is not read by the advancedsearch.php script. The bug fix remains the same: stick in the code to recognise the post variable.

Ah, I though you only wanted template controlled page limit. But this allows you to set the limit from another page, I'll add it.

But I think there should be another check in the code to see if the limit is over a specific max value, if it is the limit is set to the max limit value. That way it's not possible for users to set an limit of something like 10000 which could easily break the server. The limit could be in a .ini file to allow site adminstrators to tweak it, 30 is a good default I guess.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Jan Borsodi

Thursday 28 August 2003 4:20:48 am

It seems it's already present in 3.2, the post variable is called SearchPageLimit and the template variable search_page_limit. The $pageLimit is only used for the old code which does the search in PHP.

It also seems that the search_page_limit is not set in content/search, I'll add that too with the limiter.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Paul Forsyth

Thursday 28 August 2003 4:52:54 am

I noticed search_page_limit. I thought this would be what i wanted but if you search the php this value doesn't get passed into the ezsearch call, only $pageLimit does. $searchPageLimit is set but isnt used except to set the tpl result with.

Paul

Paul Forsyth

Thursday 28 August 2003 4:56:51 am

Thought i'd clarify what i want!

With 3.1 I designed a new advancedsearch.tpl to use the results coming from the advancedsearch.php. This still works but i need to set $pageLimit to the value i want, something different than 10. An upper bound on this value is good to have.

3.2 has the new template search but at the moment i can't spend the time redesigning the template to accomodate this. The php still works with my tpl file. Since the 3.2 code also still uses $pageLimit to define the number of search objects returned i would like that fix to be put in to allow me to set pageLimit.

paul