This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Search/Advanced search problems with...
expandshrink

Search/Advanced search problems with a user defined page limit

Search/Advanced search problems with a user defined page limit

Saturday 17 May 2003 9:11:12 pm - 8 replies

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..._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

Modified on Saturday 17 May 2003 9:12:49 pm by Paul Forsyth

Tuesday 20 May 2003 1:32:54 pm

narrowed_search working now

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

Greetings, ekke

Monday 26 May 2003 12:28:39 pm

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.

Monday 25 August 2003 1:08:20 pm

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...on/components/search/search_operator

Wednesday 27 August 2003 12:04:35 pm

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

Thursday 28 August 2003 1:16:50 pm

> 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.

Thursday 28 August 2003 1:20:48 pm

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.

Thursday 28 August 2003 1:52:54 pm

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

Thursday 28 August 2003 1:56:51 pm

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

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from