darkhoros VIP
Total posts: 152
24 Jun 2017 11:41

Hi, Please check out this link --REMOVED-- In the search area, right before the red search button there is a text field, try entering for example mountain view or new cairo, you will find that it auto completes the search based on the values available.

What I have done is, I have used mutiple level select field to strcture the values as seen in the above example, where every level is seperated by comma, so what I am missing is, how can I search in this multiple level select using auto complete text field.

I hope some one can point me to the right way. Thank you. Regards.

Last Modified: 13 Dec 2017


pepperstreet VIP
Total posts: 3,837
24 Jun 2017 23:14

Hello darkhoros, to my knowledge there is only 1 default filter template. It behaves like on form input... step by step!

filter template parameter
file

frontend
file

As you might know, simpler fields do have different template styles. Unfortunately, this hierarchical field has not.


However, you will find the template in this location:

joomla/components/com_cobalt/fields/multilevelselect/tmpl/filter/default.php

Frankly speaking, I have not the skills to create such a special filter template, but I think it is possible.
Maybe Sergey can shed some light on it...


darkhoros VIP
Total posts: 152
25 Jun 2017 00:38

I hope sergy can and even more I am willing to sponser such template Thank you


Sergey
Total posts: 13,748
26 Jun 2017 10:41

It is not easy for multiple level select. Too many conditions. I think what is possible to use select chooser Javascript that will ass search to dropdown. And then you can search on each level.


darkhoros VIP
Total posts: 152
26 Jun 2017 12:00

Hi sergy, what i was thinking is making transation database field where it compose the full muliselect field values in just on field, and then we can run the auto complete script on that new created field. Do you understand me sergy or shall i explain with an example. And as i said i dont mind sponsering such function. Thank you.


Sergey
Total posts: 13,748
27 Jun 2017 04:29

I understand what youned but miltiple level select is worst selection for this purpose. Look in example you show there is title as suggestion. This is only one level field. In multiple level fields it is nested set, it i hierarchical and it is very resources consuming to create list of possible values in one line. But it is faster if you do it by level.

I think select by level is even faster than simply suggestions. For example you selected NY and then you time mountain view in the next field. You will gen MV only in NY state. Right now you have too many anyway and it does not help, it is still hard to say which one of the list is what you need.

So I would suggest either use hierarchical selects as filter with MLS field or use another field.


darkhoros VIP
Total posts: 152
28 Jun 2017 12:29

Hi Sergy, Thank you for your kind replys. I hope you may have the time to read this full post in details.

Ok, here is how I think of it, after studing cobalt multilevel select table, in your table ech field is linked to its parent and its name, and it has IDs, the IDs are for the search value, so when you select levels and click submit, it searchs for the IDs in the submitted data, that is how it supports multilengual (correct me if I am wrong).

Based on my understanding, In my planned template for multil-level-select auto complete template, I will create a button when it is clicked it is going to build another DB table with all possible values (which in my case will not exceed 2000 and very reasnable for autocomplete search)

Example: Country ID:1 parent:0, City ID:2 parent:1, Area ID:3 parent:2, Sub-area1 ID:4 parent:3, Sub-area2 ID:5 parent:3, Sub-area3 ID:6 parent:3, and so on. The new DB table will have the following value fields:

Country-1,City-2,Area-3,Sub-area-4

Country-1,City-2,Area-3,Sub-area-5

Country-1,City-2,Area-3,Sub-area-6

And so on for DB rows End example.

Then we target the new created DB table with the auto-complete-suggestion script, and we explode the results to do arrays of names and IDs, names to be displayed for website visitors, and IDs to be used for search submmision, so when users select some text from auto complete suggestion, the IDs are represented for the search function. The suggestions should be displayed as full multi-level-select levels, so if my enter letter matches a country it displays the countries, if it matches city, then it displayes (country,city), and if it matches subarea then it shows(Country, city, area, sub area) and so on.

I am not sure how search for multi-level-selects works, dose it search for just the last value in the select levels or dose it search for the values in all select levels, in either case it will not be a problem as we have all the levels in the suggested array.

Doing it this way, it will be very user friendly, as the user will type any of the values for any of the levels then to be complete and suggested for any level using the same search field, and if same name in level 4 exists, the user will have suggestion for the full path of the whole level select values, so he can distenguish which one he nees based on the previous levels that he sees in the suggestion.

As seen in this website --LINK REMOVED-- Enter in the big text field search (mountain view icity), although the name is specific, but actlly there is 2 of them, one in Cairo and the other is in Giza, and showing the full muli-level-select in comma seperated values, help the user to select which on he wants plus the benefit of letting the user knows that there is actully 2 compounds, so you are offering him a new information that he was not aware of.

I hope you may have time to evaluate such procedure, and if there is a better way to do it from your point of view. I will be needing to hire a talent to do such job if any one is interested, reply to this post, and If I manage to get it done, I am going to contribute it to cobalt community.


Sergey
Total posts: 13,748
09 Jul 2017 06:59

Yes you can do that. But you have to take into consideration this.

  1. ther is Odessa in Ukrain and there is Odessa city in USA. SO in your index table you have to have regord for every combination.
  2. When you enter country, list of suggestions might be too long. SO you have to have only country select so that user filter only by country.
  3. What if user netered USA. Now he has too big list and he start to enter New Y... or right area of New York Brookline without city? Somehow you have to analyse string, break it into parts and search all matches.

Taking all of this into account this is the way you can do this.

Create index table of all values with data like this

Text ID
USA 12
USA, New York 3
USA, New York, Brookline 56
USA, Texis, ... 17

So you have text and ID of the last element in the string. that is all you need. Make text FULLTEXT index or create parsert to breack search string into parts.

After user selected element, just submit search form and set filter value correctly.


darkhoros VIP
Total posts: 152
02 Oct 2017 16:58

Hi sergy, Ok I have created the column with all expected values as you described, and in the other column I put the ID of the last element in the tree,

So I have exactly the table you stated with IDs as you said that is if newyork id is 3 and usa id is 12 and if brookline id is 56

The question now how do I pass the selected value from the autocomplete to the search function, and what shall I pass, do I pass the ID or the fulltext? and if I will pass the ID, how do I determine whiich level of the multiselect level to target with the search?

This is all unclear for me, if you can help me and explain more if you please.

Thank you for your time. Regards.


Sergey
Total posts: 13,748
15 Oct 2017 12:23

So all you want is to add autocomplete for filters?

My point was not to create table but rather convince you not ot because of complexity. I think the best way is to simply search in multilevel select field table. My point was that you do nto know how user enter it. If he start with country or city. You will have meke parcer for that and it is not an yeasy task.

So finaly all I wrote was to convince you that for you and your users, the best way is to use standart multiple level select field filters. the one that you start with selecting counntry, then city then area and so on is most simple for users to understand and will search articles without miss. I mean you do not have to select all the way to the end. You may only select Country and City and no area, and it will find that.


darkhoros VIP
Total posts: 152
12 Nov 2017 22:58

Hi Sergey, I think I had a working version of this at the moment.

Check this out at https://www.estamlekny.com/en/login

Scroll down to the end of the page. There is a stranded input text field, try somthing like egypt or cairo or mountain view

Auto complete is working.

All what I need now is to read the language files. I hope you have the time to check it out. Thank you.


Sergey
Total posts: 13,748
13 Dec 2017 14:20

darkhoros All what I need now is to read the language files. I hope you have the time to check it out

Please, tell me more about language file.

Powered by Cobalt