Just need to know what code I should change to get a descending (a-to-z) search order instead of an ascending search order.
Just need to know what code I should change to get a descending (a-to-z) search order instead of an ascending search order.
In Search.aspx find the code that reads
<weblink:SearchResultsBrowser8 ID="TheSearchResults" SortableColumns="COLUMN_TYPE_LASTDATE, COLUMN_TYPE_CREATEDATE" Visible="false" runat="server" ThumbnailCount="5" />
and add the following attributes to it
DefaultSortDirection="1" DefaultSortField="Name"
and add the value "COLUMN_TYPE_NAME" to the SortableColumns attribute just to be safe. It should look like
<weblink:SearchResultsBrowser8 ID="TheSearchResults" SortableColumns="COLUMN_TYPE_NAME,COLUMN_TYPE_LASTDATE, COLUMN_TYPE_CREATEDATE" DefaultSortDirection="1" DefaultSortField="Name" Visible="false" runat="server" ThumbnailCount="5" />
DefaultSortDirection 1 is for ASCENDING and 2 is for DESCENDING.
This is a great question. You will likely need to mess around with some XLST file in the WebLink files to change how the display functionality does its job. I will be watching this question to see from someone with more experience with this the precise file that would need to be edited for this functionality as I do not know it off hand.
I don't find exactly the code you mention here in Search.aspx. Here's the closest code block I've found, with the new code inserted.
<td id="TheSearchResultsPanel" valign="top"> <div id="SearchResultsDiv" class="SearchResultsContent"> <weblink:searchresultsbrowser8 SortableColumns="COLUMN_TYPE_NAME, COLUMN_TYPE_LASTDATE, COLUMN_TYPE_CREATEDATE" DefaultSortDirection="1" DefaultSortField="Name" AdditionalProperties="COLUMN_TYPE_CREATEDATE, COLUMN_TYPE_LASTDATE, COLUMN_TYPE_NUMPAGES, COLUMN_TYPE_TAGS" ThumbnailCount="5" id="TheSearchResultsBrowser" runat="server" width="100%" MaxLength="20" />
The problem is the sort order doesn't seem to change, regardless of what I set DefaultSortDirection to. Also, clicking on the Name option to sort by name doesn't seem to want to change the sort either. This refusal to resort also happens without the extra code inserted. By way of back ground, this is a search result showing folders.
Did you get this to work? Following Mike's instructions worked for me on a clean WebLink 8.2.2. I ended up with:
<weblink:searchresultsbrowser8 SortableColumns="COLUMN_TYPE_LASTDATE, COLUMN_TYPE_CREATEDATE" DefaultSortDirection="1" DefaultSortField="Name" AdditionalProperties="COLUMN_TYPE_CREATEDATE, COLUMN_TYPE_LASTDATE, COLUMN_TYPE_NUMPAGES, COLUMN_TYPE_TAGS, COLUMN_TYPE_NAME" ThumbnailCount="5" id="TheSearchResultsBrowser" runat="server" width="100%" MaxLength="20" />
One of our clients would like sorting this way as well, so I was testing it out on my demo machine to see how it works.
I am having the same issue that Alex mentioned. I thought maybe it was something in only 8.2.2 since I had 8.2.1 installed on my machine, so I upgraded to 8.2.2 and am seeing still the same code that Alex linked above. I've tried adding in the suggested additions, but still get the same search results.
I noticed that Alex was having an issue clicking on the name option, so I added a sort by option as well to see if that does anything, but sorting by entry type and entry name (search returns documents and folders) doesn't appear to do anything. I also tried this with the original code and get the same results.
Thanks,
Cody
The code appears fine. After making the changes and saving search.aspx, have you tried refreshing the page just in case there's some caching issue taking place (although normally there wouldn't be)? If you have multiple WebLink web applications with multiple copies of the Web Files folder, can you confirm that the proper copy of the search.aspx page is being modified?
You may also want to completely close and reopen the browser after making the change.
Also be aware that different search interfaces present their results on different pages. So if this is for a custom search form, you'll need to make these changes on CustomSearch.aspx. The browser URL will clarify which page is involved.