search bar

alt=
TomB
@tomb
3 years ago
10 posts
Hi everyone,
I have a question about how the search bar works. The JrCore_list creates an output of a list of elements. If it is combined with the jrSearch_module_form with specific search parameters, how do these two influence each other? Is there a weighing of certain parameters? And are the two searching parameters combined with a "with" or "and" query?

Thank you for your help
updated by @tomb: 09/07/21 02:46:50AM
michael
@michael
3 years ago
7,692 posts
jrCore_list will go grab a list of whatever its been requested to get.

Jamroom has a system called 'events' and 'listeners':

Docs: Events and Listeners
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1011/events-and-listeners

in summary, there are a bunch of 'events' around the place that other modules can 'listen' for. This allows another module to manipulate the data without each module needing to know that the other exists.

During the jrCore_list call the jrSearch module registers a listener. When the point in the code is reached the query that the jrCore_list call is building is passed to the event which shares it around any module with a registered listener; they do what they want to with the data then pass it back into the flow.

After the jrSearch module has finished it's changed the SQL query that is being run. I think from memory what it does is it grabs a list of items that match the search term and then passes those ids into the main query in an
_item_id IN(1,2,3,4,8,67,95,124)
type structure, so only the items in the originally requested jrCore_list call that are also in the list of item_id's that have the search term in them are returned.
alt=
TomB
@tomb
3 years ago
10 posts
Thank you for your quick answer.
The question is, is the order parameter JrCore_list overwritten, or do we have to exclude it?
The example:
{jrCore_list module="jrRedBook" template="{$_conf.jrRedBook_redbook_view_index}.tpl" quota_check=false order_by="redbook_order_string asc" pagebreak=30 page=$_post.p pager=true fdebug=false search1="profile_quota_id in 1,6,7,9" search2="profile_lastname != NULL" search3="redbook_deactivate_entry != on" search4="profile_lastname like `$_post._1`%" }
The search results order is always redbook_order_string, although other fields in the RedBook have a higher weighing.
A possible solution may be: We intercept the search parameter {if isset($_post.ss)}, so that we can exclude the order_by, to get the wanted searching criteria?
michael
@michael
3 years ago
7,692 posts
That's a hard one to do in my head.

The jrCore_list function is just a wrapper for the jrCore_db_search_items() function.

If order is important take a look in /modules/jrCore/lib/datastore.php for a function _jrCore_db_search_items() and check out all the events that happen in there.

A solution could be that after the search results have been found you use a 'listener' to re-apply the order.

The events in that function are:
* 'db_search_params'
* 'db_search_cache_check'
* 'db_search_simple_keys'
* 'db_search_count_query'
* 'db_search_items_query'
* 'db_search_items'
* 'db_search_results'

So there's a lot of locations to choose from in that flow.
WebServices
WebServices
@swenmaertin
3 years ago
11 posts
Thank you very much. I'm sure it's difficult.

We'll take a look at it.

Best regards
Swen

Tags