Show TOC

Background documentationUsing the Search API Locate this document in the navigation structure

Example

The following examples illustrate how to use the Search API:

Example Example

Displaying a list of the search providers registered in the portal
  1. EPCM.getSAPTop().LSAPI.getSearchProviderPlugin().getProviders(initProvidersList);
    
    //Display a menu with a list of search providers
    	function initProvidersList(searchProvidersList)
    {
    		if( searchProvidersList ) 
    		{
    			var SearchMenuItems = [];
    			for( var i = 0 ; i < searchProvidersList.length ; i++ )
    			{
    				var currSearchProvider = searchProvidersList[i];
    				SearchMenuItems[i] = {
    					id:	currSearchProvider.getKey(),
    					title:  	currSearchProvider.getName(),
    					click:  	navigateToItem(currSearchProvider.getKey(), currSearchProvider.getNavigationType),    
    // 'navigateToItem' is a method which needs to be implemented
    					searchTypes: currSearchProvider.getSearchTypes()
    				}
    			}
    		}
    };
    
End of the code.

Example Example

Displaying the categories for the default provider
  1. Function getCategories()
    {
    	var defaultSearchProvider  = EPCM.getSAPTop().LSAPI.getSearchProviderPlugin().getDefaultProvider();
    	var searchTypes = defaultSearchProvider .getSearchTypes();
    	for( var i = 0 ; i < searchTypes.length ; i++ )
    	{
    		var currSearchType = searchTypes[i];
    		var categories = currSearchType.getCategories();
    		for( var j = 0 ; j < categories.length ; j++ )
    		{
    			var currCategory = categories[j];
    			var categoryID = currCategory.getID();
    			var categoryTitle = currCategory.getTitle();
    			var categoryURL = currCategory.getCategoryURL(); 
    			//...
    			//Display a list of these categories
    			// ...
    		}
    	}	
    }
    
End of the code.