Customisation Title | Alphabetically sorting the Slices in the Search Bar |
---|---|
Purpose of Customisation | To alphabetically sort the list of Slices that a user can search in from the Search dialog in the Livelink header. |
Author | Greg Griffiths |
Date of Customisation | 02 March 2004 |
Covers Livelink | Livelink 9 |
Livelink Modules | WebSearchBroker |
Affected Templates | \websbroker\html\fieldbrokerlist.html |
Customisation Format | HTML |
Download Here | Download as a ZIP file (Pre 9.2) Download as a ZIP file (9.2+) |
Several recent requests in the Livelink Knowledge Center concerned sorting the list of Slices - listed in the dropdown list on every Livelink page - in alphabetical order. Having written some code to sort Form View Names in a Form Template I already hade most of the code prewritten for this.
The main difference between the requirements for that customisation and this one where :
- Only sort the Slices and not the entire menu.
- The assignment of a default selected item is handled by another script and should not be handled by mine.
;if ( showGlobalSlice ) && IsDefined( bsModule )
<OPTION VALUE="">--------
<OPTION VALUE='GlobalSearch'>`[WebBrokeredSearch_HTMLLabel.GlobalSearch]`
<OPTION VALUE="`.URL()`?func=bs.prompt">`[WebBrokeredSearch_HTMLLabel.GlobalSearchExpanded]`
;end
</SELECT>
<script>
var arr_optionsValue = new Array(); // array to hold the Value of the OPTIONS
var arr_optionsText = new Array(); // array to hold the Text of the OPTIONS
var ds; // Index of current selected Option
var theDD; // reference to the Drop Down
var startPos=0; // reference to the first Slice
// if on the Standard Search Page
if (document.SearchBarForm)
{
theDD=document.SearchBarForm.collections_search_selected;
}
// if on the Advanced Search Page
if (document.searchFrm)
{
theDD=document.searchFrm.collections_search_selected;
}
// find the location of the seperator
for (count=0;count<theDD.options.length;count++)
{
if (theDD.options[count].text=="--------")
{
startPos=count+1;
break;
}
}
// get the text of each OPTION tag
for (count=startPos;count<theDD.options.length;count++)
{
arr_optionsText[count] = theDD.options[count].text;
}
// sort the array
arr_optionsText.sort();
// add the values
for (i=0;i<arr_optionsText.length;i++)
{
for (j=0;j<theDD.options.length;j++)
{
if (theDD.options[j].text==arr_optionsText[i])
{
arr_optionsValue[i]=theDD.options[j].value;
}
}
}
// cut the list to just be the main search areas
theDD.options.length=startPos;
// add the slices in alphabetical order
for (i=0;i<(arr_optionsText.length-startPos);i++)
{
theDD.options[i+startPos]= new Option(arr_optionsText[i],arr_optionsValue[i]);
}
</script>
;;end
;end
;end
</SELECT>
<script>
var arr_optionsValue = new Array(); // array to hold the Value of the OPTIONS
var arr_optionsText = new Array(); // array to hold the Text of the OPTIONS
...
;if Length( withinQuery ) > 0
// Display the within line if this is a popup, if it is a selected scope, or
// if FromHereExpanded is 'TRUE' because we just came from a popup.
;if ( doPopup || _WithinSelected( hilightList ) || request.FromHereExpanded == 'TRUE' )
<OPTION SELECTED VALUE="`Str.String( brokersRec[1 ].DATAID ) + '&' + locationId + '&' + locationName `">`brokersRec[ 1].NAME`</OPTION>
;end
;if doPopup
<OPTION VALUE="`.URL()`?func=ll&objType=258&objAction=searchprompt&locationId=`locationId`&locationName=`Web.Escape( locationName)`&withinQuery=TRUE&FromHereExpanded=TRUE">`[WebSBroker_HTMLLabel.FromHereExpanded]`</OPTION>
<OPTION VALUE="">--------</OPTION>
;end
;if ( doPopup || ( IsFeature( request,'FromHereExpanded' ) && request.FromHereExpanded == 'TRUE' ) )
;for i = 2 to Length( brokersRec )
<OPTION VALUE="`brokersRec[ i].DATAID`">`brokersRec[ i ].NAME`</OPTION>
;end
;else
;for i = 2 to Length( brokersRec )
;rec = brokersRec[ i ]
;IsInList = False
;if ( ( rec.DATAID in hilightList ) && (rec.DATAID != libraryReference ) )
;IsInList = True
;end
<OPTION `( IsInList ) ? "SELECTED" : ""`VALUE="`rec.DATAID`">`rec.NAME`</OPTION>
;end
;end
;else
;for i = 1 to Length( brokersRec )
;rec = brokersRec[ i ]
;IsInList = False
;if ( ( rec.DATAID in hilightList ) || ( i == 1&& noDefaultSelection( brokersRec, hilightList ) ) )
;IsInList = True
;end
<OPTION `( IsInList ) ? "SELECTED" : ""`VALUE="`rec.DATAID`">`rec.NAME`</OPTION>
;end
;end
;boolean showGlobalSlice = true;
;if IsDefined( request )
;if IsFeature( request, 'objAction' ) && ( !Str.CmpI(request.objAction ,'searchprompt' ) )
;showGlobalSlice = false;
;end
;end
;if ( showGlobalSlice ) && IsDefined( bsModule )
<OPTION VALUE="">--------</OPTION>
<OPTION VALUE='GlobalSearch'>`[WebBrokeredSearch_HTMLLabel.GlobalSearch]`</OPTION>
<OPTION VALUE="`.URL()`?func=bs.prompt">`[WebBrokeredSearch_HTMLLabel.GlobalSearchExpanded]`</OPTION>
;end
Current | New |