New in Jomres 10.2 is a feature that I'm calling Data Sources.
How did I arrive at this feature? Well, it's a bit of a long story.
Autocomplete features are popular on booking websites. See for example the "Where are you going" input field on booking.com. Type the name of a town, city or country in there and you'll see a response that autopopulates that field and makes searching simpler.
I'm not really a fan of these types of inputs for all booking sites because they involve a certain amount of guesswork on the part of the site visitor. For booking.com it works because quite frankly they've got something everywhere. For smaller site users the likely results are going to be a little more hit and miss. Another reason I'm not a fan is that every character that's typed in the input field requires an ajax call and one or more database queries while the server searches for matching responses. It works, but it's not always the fastest way of doing things (plus it's a performance hit).
Nevertheless, clients like the feature.
So....what to do?
Well, for years Jomres has had some autocomplete functionality in older search modules and indeed when I created the new Search Widget plugins I ported that functionality into the Search Widget functionality but in truth I don't like it and I don't think it works very well. I really wanted to avoid constantly making queries to find published property towns, cities and countries.
Enter "Data Sources"
Honestly, it's a bit of a crap name for the feature, but at the time I was thinking about making it work and potential implications for it's use rather than finding a really good name for it so that's what we've got. Suck it up, soldier.
Currently, every time a dropdown for a search form for country, region or town is generated in Jomres this dropdown is populated from results of search queries. It's done this way to ensure that the countries/regions/towns in the dropdowns are from fresh data. As a user, to me there's nothing more infuriating than visiting a website, being offered a dropdown to find something on their site, selecting an option and doing the search just to be told "Sorry, there were no results". To me it stinks of unprofessionalism, poor coding and really sloppy attempts at gaming SEO. If you want to please Google, that's great but if you're just annoying your site visitors, what's the point?
What I really wanted to do was build a better store of the information that's used to build these dropdowns that didn't have the database/network hit but was still blazingly fast.
Here's what we've got so far. Data Sources used by the new autocomplete functionality found in the Search Widget plugin that will be released when Jomres 10.2 is released. Type in text such as Th (for Thailand) and you'll see that the autocomplete results are returned very quickly.
Data Sources is, at it's heart, a cache of town, region and country names. The data is generated automatically when Jomres notices that the relevant data source files don't exist and then every time a property is added, updated or removed this data is refreshed by the webhook watcher feature in Jomres. This cache is sensitive to the currently active language so different languages will have different locales available.
The feature creates new cache files in the jomres/temp directory which can then be accessed by other functionality. For example, on the Jomres Joomla 4 development server these are the files created :
http://joomla4.jomres.net/jomres/temp/data_cache/data_source_countries.json
http://joomla4.jomres.net/jomres/temp/data_cache/data_source_regions.json
http://joomla4.jomres.net/jomres/temp/data_cache/data_source_towns.json
Right now just the autocomplete functionality (food for another blog post) uses this data however when time allows I'll modify the search widget plugin to use it too which will be a performance saving. The really nice thing about this feature is that A the data is kept fresh by the webhook watcher, and B because the data's in JSON format in documented files you could create your own search functionality that uses that data without needing to hook into the Jomres framework if you don't want to.
There is also scope for extending the Data Sources functionality to include room types, property types etc too but I'll wait to see if they're needed.
So ends my first Technical Blog post. I hope that the information here has tickled your technical itch and you get something out of it.
- Created on .