In this post you can see how to create a Custom Section (for ex:
'ContentTypeRefiner') in the SharePoint 2010 search refinement panel.
I have seen many posts everyone saying that create a custom search
page and add refinement web part. But in this example I am using out of box OssSearchResults.aspx (located under 14 hive layouts
folder). Before modifying this page take a backup of this file.
You can see below webpart code in the OssSearchResults.aspx
page.
when you use below tag by default it shows below sections
Restult Type
Site
Author
Modified Date
Managed Metadata (if you have)
<SearchWC:RefinementWebPart runat="server" FrameType="None" UseDefaultConfiguration="true"
></SearchWC:RefinementWebPart>
If you want to add any custom section then only you need to
modify this web part. In my case I am adding below part. I have created my own Managed property called 'ContentTypeRefiner'.
You can see in the below post how to create a managed property
for search
<Category
Title='ContentTypeRefiner'
Description='Which site this
document is from'
Type='Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator'
MetadataThreshold='5'
NumberOfFiltersToDisplay='4'
MaxNumberOfFilters='20'
SortBy='Frequency'
SortByForMoreFilters='Name'
SortDirection='Descending'
SortDirectionForMoreFilters='Ascending'
ShowMoreLink='True'
MappedProperty='ContentTypeRefiner'
MoreLinkText='show more'
LessLinkText='show fewer'
/>
<%--SearchWC:RefinementWebPart
runat="server" FrameType="None"
UseDefaultConfiguration="true"
--%>
Just comment existing SearchWC:RefinementWebPart code and replace with below
code. Then you can see custom section in the panel.
Please keep
in mind below tag should be in one line. Otherwise you can see the errors when you
open this page in visual studio.
<SEARCHWC:RefinementWebPart runat="server" Description="This webpart helps the users to refine search
results" UseDefaultConfiguration="false"
FilterCategoriesDefinition="<?xml
version='1.0' encoding='utf-8'?> <FilterCategories> <Category Title='Result Type' Description='The file extension of the
item' Type='Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator' MetadataThreshold='5' NumberOfFiltersToDisplay='4' MaxNumberOfFilters='0' SortBy='Frequency' SortDirection='Descending' SortByForMoreFilters='Name' SortDirectionForMoreFilters='Ascending' ShowMoreLink='True' MappedProperty='FileExtension' MoreLinkText='show more' LessLinkText='show fewer'> <CustomFilters
MappingType='ValueMapping' DataType='String' ValueReference='Absolute' ShowAllInMore='False'> <CustomFilter CustomValue='Adobe
PDF'>
<OriginalValue>pdf</OriginalValue> </CustomFilter> <CustomFilter
CustomValue='Email'>
<OriginalValue>eml</OriginalValue> <OriginalValue>msg</OriginalValue>
<OriginalValue>exch</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Excel'>
<OriginalValue>odc</OriginalValue>
<OriginalValue>ods</OriginalValue> <OriginalValue>xls</OriginalValue> <OriginalValue>xlsb</OriginalValue>
<OriginalValue>xlsm</OriginalValue>
<OriginalValue>xlsx</OriginalValue> </CustomFilter> <CustomFilter
CustomValue='Image'>
<OriginalValue>tif</OriginalValue> <OriginalValue>tiff</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Lotus
Notes'>
<OriginalValue>nsf</OriginalValue> </CustomFilter> <CustomFilter
CustomValue='OneNote'>
<OriginalValue>one</OriginalValue> </CustomFilter> <CustomFilter
CustomValue='PowerPoint'>
<OriginalValue>odp</OriginalValue>
<OriginalValue>ppt</OriginalValue>
<OriginalValue>pptm</OriginalValue>
<OriginalValue>pptx</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Publisher'>
<OriginalValue>pub</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Text'>
<OriginalValue>odt</OriginalValue>
<OriginalValue>txt</OriginalValue> <OriginalValue>url</OriginalValue>
<OriginalValue>csv</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Visio'>
<OriginalValue>vdw</OriginalValue>
<OriginalValue>vdx</OriginalValue> <OriginalValue>vsd</OriginalValue> <OriginalValue>vss</OriginalValue>
<OriginalValue>vst</OriginalValue>
<OriginalValue>vsx</OriginalValue>
<OriginalValue>vtx</OriginalValue> </CustomFilter> <CustomFilter
CustomValue='Webpage'>
<OriginalValue>ascx</OriginalValue>
<OriginalValue>asp</OriginalValue>
<OriginalValue>aspx</OriginalValue> <OriginalValue>htm</OriginalValue>
<OriginalValue>html</OriginalValue>
<OriginalValue>jhtml</OriginalValue> <OriginalValue>js</OriginalValue>
<OriginalValue>mht</OriginalValue>
<OriginalValue>mhtml</OriginalValue> <OriginalValue>mspx</OriginalValue>
<OriginalValue>php</OriginalValue>
<OriginalValue></OriginalValue> </CustomFilter> <CustomFilter
CustomValue='XML'>
<OriginalValue>xml</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Word'>
<OriginalValue>doc</OriginalValue>
<OriginalValue>docm</OriginalValue> <OriginalValue>docx</OriginalValue>
<OriginalValue>dot</OriginalValue>
<OriginalValue>nws</OriginalValue> </CustomFilter> <CustomFilter
CustomValue='Zip'>
<OriginalValue>zip</OriginalValue> </CustomFilter> </CustomFilters> </Category> <Category Title='Site' Description='Which site this document is
from' Type='Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator' MetadataThreshold='5' NumberOfFiltersToDisplay='4' MaxNumberOfFilters='20' SortBy='Frequency' SortByForMoreFilters='Name' SortDirection='Descending' SortDirectionForMoreFilters='Ascending' ShowMoreLink='True' MappedProperty='SiteName' MoreLinkText='show more' LessLinkText='show fewer' /> <Category Title='ContentTypeRefiner' Description='Which site this document is
from'
Type='Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator' MetadataThreshold='5' NumberOfFiltersToDisplay='4' MaxNumberOfFilters='20' SortBy='Frequency' SortByForMoreFilters='Name' SortDirection='Descending' SortDirectionForMoreFilters='Ascending' ShowMoreLink='True' MappedProperty='ContentTypeRefiner' MoreLinkText='show more' LessLinkText='show fewer' /> <Category Title='Author' Description='Use this filter to restrict
results authored by a specific author'
Type='Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator' MetadataThreshold='5' NumberOfFiltersToDisplay='4' MaxNumberOfFilters='20' SortBy='Frequency' SortByForMoreFilters='Name' SortDirection='Descending'
SortDirectionForMoreFilters='Ascending' ShowMoreLink='True' MappedProperty='Author' MoreLinkText='show more' LessLinkText='show fewer' />
<Category Title='Modified
Date' Description='When the item was
last updated'
Type='Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator' MetadataThreshold='5' NumberOfFiltersToDisplay='6' MaxNumberOfFilters='0' SortBy='Custom' ShowMoreLink='True' MappedProperty='Write' MoreLinkText='show more' LessLinkText='show fewer' > <CustomFilters
MappingType='RangeMapping' DataType='Date' ValueReference='Relative' ShowAllInMore='False'> <CustomFilter CustomValue='Past 24
Hours'>
<OriginalValue>-1..</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Past
Week'>
<OriginalValue>-7..</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Past
Month'>
<OriginalValue>-30..</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Past Six
Months'>
<OriginalValue>-183..</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Past
Year'>
<OriginalValue>-365..</OriginalValue> </CustomFilter> <CustomFilter CustomValue='Earlier'>
<OriginalValue>..-365</OriginalValue> </CustomFilter> </CustomFilters> </Category> <Category Title='Managed Metadata Columns' Description='Managed metadata of the
documents'
Type='Microsoft.Office.Server.Search.WebControls.TaxonomyFilterGenerator' MetadataThreshold='3' NumberOfFiltersToDisplay='3' MaxNumberOfFilters='20' ShowMoreLink='True'
MappedProperty='ows_MetadataFacetInfo' MoreLinkText='show more' LessLinkText='show fewer' /> <Category Title='Tags' Description='All managed metadata of the
documents and social tags'
Type='Microsoft.Office.Server.Search.WebControls.TaxonomyFilterGenerator' MetadataThreshold='3' NumberOfFiltersToDisplay='3' MaxNumberOfFilters='20' ShowMoreLink='True'
MappedProperty='ows_MetadataFacetInfo,popularsocialtags' MoreLinkText='show more' LessLinkText='show fewer' /> </FilterCategories>"
/>
No comments:
Post a Comment