Application search can be enhanced by making various modifications to your portal. In this workshop, we show you how to add dynamic suggestion lists to existing search functionality so that previous search terms can be saved and search words can be used to open Google or Wikipedia.

1. Passing on search terms to search engines

A simple modification is calling search engines such as Google or encyclopedias such as Wikipedia with the search term entered. If required, the user can click a button to open the desired webpage and transfer the search term.

Next to the Intrexx search control we add an image button with a fitting icon and call a function on the onclick event named searchengineSearch().

As a parameter we use a string containing the name of the desired search engine. In our example we use “google” and “wikipedia”. Of course the function can also be extended to other providers by customising the case blocks. The GUID needs to be the GUID of the search field so that the JavaScript function can get the search term.



function searchengineSearch(p_type)
{
	var l_strSearchterm = getElement("GUID").value; /*Search textcontrol*/
	var l_url = "";
	if(l_strSearchterm!= "" || l_strSearchterm!= " ")
	{
		switch(p_type)
		{
			case "google":
			l_url = "http://www.google.com/search?q=" + l_strSearchterm;
			break;
			case "wikipedia":
			l_url = "http://en.wikipedia.org/w/index.php?search=" + l_strSearchterm;
			break;
		}
		// Call
		Searchengine = window.open(l_url, "Search Engine");
		Searchengine.focus();
	}
	return true;
}


2. Suggestions

Surely you know the search engine function that provides search term suggestions already while entering the word you are searching for. This kind of functionality can also be implemented in Intrexx. Therefore we add a new text-button on the page, move it into a grouping which gets the style “Container_Hidden”. This way the grouping including the button will be hidden. The button will be named “_Datapicker_Suggestions“.

In addition we need to create a new data group “_hlp TopSearchEntries” containing a list of suggestions. It includes a short text field for the search terms. This data group will be filled with the help of the Data Transfer module in the Integration Center with values from CSV files or Excel tables.

Lists with search terms in different languages can be downloaded from the University of Leipzig:
http://wortschatz.uni-leipzig.de/html/wliste.html

For example the Top 1000 in English:
http://wortschatz.uni-leipzig.de/Papers/top10000en.txt

In this example we create a new data transfer and select the option to import data from a text file.



The source file is the top10000en.txt we downloaded from the University of Leipzig.


Target is the current portal.


The data should be transferred to the “_hlp TopSearchEntries” data group.


Link the Searchterm field to the column1 and create a new auto value for the ID.


Then go through the next steps and start the import.

The data picker now needs to be configured for the imported search terms. It is required to select the data group “_hlp TopSearchEntries” and the data field “Searchterm”.


It is also important to configure the page with the results set. The column selected needs to be “Searchterm“ and the data picker should be called automatically when entering more than 3 characters. This way the suggestion list will be generated dynamically.


If the users select one of the suggested terms we would like to activate the search. Therefore we call a new function clickSearchButton () on the onmatch event. This setting can also be found in the advanced settings of the data picker.


The function clickSearchButton simply clicks the search button on our page. The GUID needs to be changed to the GUID of your search button.

function clickSearchButton ()
{
	var oBtnSearch = getElement("GUID"); /*Search  buttoncontrol*/
	oBtnSearch.onclick();
	return true;
}


United Planet
Intrexx Application Store Press Downloads
English