Keep search term in the search widget field when moving from page to page with paginator

simelas 22 Aug, 2018
Answer
2 Likes
Hello everyone, hello Max

Question came few times : is there a simple way to keep the search term in the search field of the search widget, while moving from page to page with the paginator.

(This show an example of the solution i applied for Chronoconnectivity6 with the search widget but can be applied to any selector /filter.

Explanation: Currently (01 September2018) when filtering a database with the "Search Widget" , having set Model.field:{data:keywords}/- in the WHERE conditions of the database read function, the behaviour is as expected. e.g. the filter works properly.

However when moving from one page to the other using the paginator, the value in the search field is erased at the first move.

Debug show that on initial run: e.g. on using the search button, the keywords field if correctly filled. ( As example here i used [keywords] =>fire ; having on purpose worked with "Build a Basic lisitng" ).
Array
(
[option] => com_chronoconnectivity6
[cont] => manager
[conn] => article
[event] => index
[text5] =>
[keywords] => fire
Then when clicking on one of the paginator page , the filter is reset to blank,more precisely the additonnal parameter ( in the present case [keywords] => fire ) is not included in the paginator url of the paginator
Array
(
[option] => com_chronoconnectivity6
[cont] => manager
[conn] => article
[event] => index
[startat] => 0
(If after having filtered, one add manually a parameter to the paginator ( &keywords=fire) then the paginator works as expected : e.g. one can navigate through the paginated views with the paginatorkeeping the filtered data. Conclusion: the search parameter is not properly passed to the paginator (or this is not the right method)).



Solution applied:

In the relevant Form area of the Views tab add in Submit event , an event name that you can call 'select' for exemple.

In the Functions tab add a redirect action named for example "redirect_select' and for that redirect action add: in "Event" add index ; in "Redirect URL" add {url_self} ; in "URL Parameters" add the parameters of the desired filter field(s) , for example keywords={data:keywords} state={data:state} country_id_select={data:country_id_select} .

In Events tab add a new event named 'select'. In this event add {fn:redirect_select} and {redirect:index}

Save your connection and test. Now the paginator should behave as expected when using filters.


Several post in the forum ask for a solution and some solutions seems to have been proposed but nothing definitively crystal clear. Maybe there is a simpler way than the one proposed but at least it works well.

Maybe Max could you work a little bit on that matter.

Best Regards,

simelas
murilolule 01 Aug, 2019
Hello simelas!
I am using chronoconectivity version 6.1.
I have the same problem: I have a "Search" field and use what is typed there to search my table.
This works well, but when I use the paginator and change the page, the results appear as if they have no filter.

The above solution did not work for me. Can you see any other way?
simelas 23 Aug, 2019
Hello murilolule,
The proposed solution works well with all versions of CC6. Could you please be more specific or pm a screen shot of your setting or pm an admin code such as i can have a look /check on your site.

simelas@simelas.com
murilolule 26 Aug, 2019
In the end I can develop my search form.
I was not understanding the function of the "Search parameter name" field. It was blank.
I created a "Read Data" with "select type" -> "all matching records" with the "sortable fields" as "readdatamodel.name", "readdata. Lecture".
"Search parameter name" is set to "keywords"
and "Searchable fields" as "name".
After correctly setting the fields, the "search" widget worked.

Thanks for your attention and sorry for missing my return.
The result is here: https://www.educatu.com.br/transparencia/inscri%C3%A7%C3%B5es/lista-replanejamento-2019.html?conn=contando-registros
joaoparao 10 Apr, 2020
Hi Simelas,
I followed your instructions to ensure that the search was maintained even
with the use of paginators, but I did not succeed: I did not understand
what you mean by "In the relevant Form of the Views tab add an event
that you can call 'select' for exemple ". What kind of event should I
create in Views?
If you can send me an example I would be grateful to you.
Among other things, I use a dropdown that automatically selects the
values of a field in the database to be searched.
Jo
simelas 12 Apr, 2020
Hi Joaparao,

maybe it is more clear to read it as such: In the relevant Form area of the Views tab add in Submit event , an event name that you can call " select " for exemple.

I have edited my previous post accordingly.

Nevertheless please see hereafter some more step by step explanations:

Let assume you want to filter countries with a drop down named for example " field_select_my_dropdown_for_countries " and that your drop down field name is " country_id_select " and that your database table contain a field named " country_id ".

In the tab Functions, your function Read Data should contain " country_id:{data:country_id_select}/- " in the WHERE conditions.

In that same Functions tab, add a function and name it " redirect " . Then in Name put " redirect_select " . In Redirect URL put " {url:} " and in URL parameters put " country_id_select={data:country_id_select} "

In the tab Events, create an event called for example " select " and add in that event " {fn:redirect_select} " and " {redirect:index} ".

In the tab Views, for your form area which contain your dropdown view for example " {view:field_select_my_dropdown_for_countries} " put " select " in the Submit Event.

(Your paginator should be in the event " index " of the tab Events or should be called by a view related to the event " index " in the tab Events).

That's all!

hope it helps

simelas
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger