New ajax powered smart search functionality in ATK
April 16th, 2006 by Ivo
Together with comunication firm Effectiv we developed a marketing tool for Cirque du Soleil in ATK. For this application, we needed a better way to search through the myriad of data in their database. Peter solved this by adding a new nifty Ajax powered search functionality to ATK, that can be used to traverse all data, following relationships and exposing the entire database through a single interface.
An example of the type of searches that a user can do: 'show all employees that work in a department whose manager lives in a city that has at least 10.000 inhabitants'.
This functionality is available in the current nightly build. (This contains only the atk subdir, if you don't have an ATK app already, download the sample application first.)
Here is a screenshot:

In this screenshot, I am looking for all employees whose manager is 'ivo', and that work in a department which is currently hiring. (this is taken from lesson 3 of the demo application)
In ATK tradition, to enable the functionality you need only one line of code. Just add the following code to any node (constructor or action_admin override):
$this->setExtendedSearchAction('smartsearch');
(Note1: if you do not have AF_SEARCHABLE attribs, make sure you set NF_EXTENDED_SEARCH to force display of the search bar. Note 2: in a future nightly this will be even easier through the use of a new NF_SMART_SEARCH flag)
Now, click the 'extended' link in your application's search bar to get the new search.
Another neat feature is the possibility to save and load sets of search criteria. To enable this, you need to have the atk_smartsearchcriteria table:
CREATE TABLE atk_smartsearchcriteria ( nodetype VARCHAR(100) NOT NULL, name VARCHAR(100) NOT NULL, criteria TEXT NOT NULL, PRIMARY KEY (nodetype, name) );
Peter did a great job with this feature. I think this opens the road for advanced reporting functionality in ATK.
April 16, 2006 at 3:26 pm, Markus Wolff said:
I have no doubt this is, from a technological point of view, a great new feature. However, looking at the screenshot reveals one obvious flaw for the end-user. Can you spot it?
April 16, 2006 at 6:47 pm, Ivo Jansch said:
I’m not sure I see it.. if you mean the lack of a ‘save’ button next to the saved search; it saves when you search (although I agree this could be argued against, as the user hasn’t seen any results yet). Is that what you meant?
April 18, 2006 at 10:47 am, Markus Wolff said:
Nope. I meant “Search for a substring” – I doubt that any “normal” non-geek user will know what a string is, and a substring will raise even more question marks
Okay, that may be a bit picky, but it’s the little things…