SharePoint 2010: Sites That I Have Access To Web Part
Laura Rogers (aka @wonderlaura) has a post on her site about utilizing the Search Core Results web part to create a data view of sites that a user has access to. I’ve been utilizing this functionality in several places lately and thought it might be helpful to have the web part definition handy (why recreate the wheel?).
The following definition provides a single column view, with just the title field from the search results formatted as a link to the site (using the url field).
Web Part Definition
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart, Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="SpellcheckingMode" type="Microsoft.Office.Server.Search.Query.SpellcheckMode, Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Suggest</property>
<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
<property name="AllowConnect" type="bool">False</property>
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="CharactersInUrl" type="int">90</property>
<property name="ShowLangPicker" type="bool">True</property>
<property name="DisplayName" type="string" />
<property name="MoreLinkUrl" type="string" null="true" />
<property name="Title" type="string">Search Core Results</property>
<property name="ShowActionLinks" type="bool">False</property>
<property name="ViewFlag" type="string">0</property>
<property name="QueryNumber" type="Microsoft.Office.Server.Search.WebControls.QueryId, Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Query2</property>
<property name="PreviewWindowSize" type="string">160</property>
<property name="DateFormat" type="Microsoft.SharePoint.Utilities.SPDateFormat, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">DateOnly</property>
<property name="AllowClose" type="bool">True</property>
<property name="SentencesInSummary" type="System.Int16, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">3</property>
<property name="HighestResultPage" type="System.Int16, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">1000</property>
<property name="CacheXslTimeOut" type="int">86400</property>
<property name="RelevanceView" type="bool">False</property>
<property name="MoreLinkLabel" type="string">View more results »</property>
<property name="ManualRefresh" type="bool">False</property>
<property name="ListUrl" type="string" null="true" />
<property name="FixedQuery" type="string">contentclass:STS_Site contentclass:STS_Web contentClass:sts_listitem_850</property>
<property name="CacheXslStorage" type="bool">True</property>
<property name="ResubmitFlag" type="Microsoft.Office.Server.Search.Query.ResubmitFlag, Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">NoResubmit</property>
<property name="XslLink" type="string" null="true" />
<property name="EnableStemming" type="bool">False</property>
<property name="ShowSearchResults" type="bool">True</property>
<property name="AllowMinimize" type="bool">True</property>
<property name="AllowHide" type="bool">True</property>
<property name="ShowMoreLink" type="bool">False</property>
<property name="ListDisplayName" type="string" null="true" />
<property name="ChromeType" type="chrometype">None</property>
<property name="EnableDocumentPreviewPowerPoint" type="bool">True</property>
<property name="DefaultRankingModelID" type="string" />
<property name="CatalogIconImageUrl" type="string" />
<property name="Default" type="string" />
<property name="DisplayRSSLink" type="bool">False</property>
<property name="FireInitialRow" type="bool">True</property>
<property name="TotalNumberDocumentPreview" type="string">10</property>
<property name="DateView" type="bool">False</property>
<property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">None</property>
<property name="DisplayAlertMeLink" type="bool">False</property>
<property name="DataSourceID" type="string" />
<property name="HelpUrl" type="string" />
<property name="DisplayDiscoveredDefinition" type="bool">True</property>
<property name="AppendedQuery" type="string" />
<property name="AsyncRefresh" type="bool">False</property>
<property name="IgnoreNoise" type="bool">True</property>
<property name="Height" type="string" />
<property name="PageSize" type="int">-1</property>
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="AllowEdit" type="bool">True</property>
<property name="ViewContentTypeId" type="string" />
<property name="Hidden" type="bool">False</property>
<property name="DefaultSort" type="Microsoft.Office.Server.Search.WebControls.ResultsView, Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Modified_Date</property>
<property name="ExportMode" type="exportmode">All</property>
<property name="ConcurrentNumberDocumentPreview" type="string">10</property>
<property name="ListName" type="string" null="true" />
<property name="PropertiesToRetrieve" type="string"><Columns> <Column Name="WorkId"/> <Column Name="Rank"/> <Column Name="Title"/> <Column Name="Author"/> <Column Name="Size"/> <Column Name="Path"/> <Column Name="Description"/> <Column Name="Write"/> <Column Name="SiteName"/> <Column Name="CollapsingStatus"/> <Column Name="HitHighlightedSummary"/> <Column Name="HitHighlightedProperties"/> <Column Name="ContentClass"/> <Column Name="IsDocument"/> <Column Name="PictureThumbnailURL"/> <Column Name="PopularSocialTags"/> <Column Name="PictureWidth"/> <Column Name="PictureHeight"/> <Column Name="DatePictureTaken"/> <Column Name="ServerRedirectedURL"/> </Columns></property>
<property name="ParameterBindings" type="string" null="true" />
<property name="DataSourcesString" type="string" />
<property name="EnablePhonetic" type="bool">False</property>
<property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="Scope" type="string" />
<property name="XmlDefinitionLink" type="string" />
<property name="DataFields" type="string" />
<property name="ShowMessages" type="bool">False</property>
<property name="Width" type="string" />
<property name="InitialAsyncDataFetch" type="bool">False</property>
<property name="QuerySideLanguage" type="string">-1</property>
<property name="MoreResultsLink" type="string" null="true" />
<property name="XmlDefinition" type="string" />
<property name="ChromeState" type="chromestate">Normal</property>
<property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
<property name="ScopeID" type="int">1</property>
<property name="SelectColumns" type="string"><Columns> <Column Name="WorkId"/> <Column Name="Rank"/> <Column Name="Title"/> <Column Name="Author"/> <Column Name="Size"/> <Column Name="Path"/> <Column Name="Description"/> <Column Name="Write"/> <Column Name="SiteName"/> <Column Name="CollapsingStatus"/> <Column Name="HitHighlightedSummary"/> <Column Name="HitHighlightedProperties"/> <Column Name="ContentClass"/> <Column Name="IsDocument"/> <Column Name="PictureThumbnailURL"/> <Column Name="PopularSocialTags"/> <Column Name="PictureWidth"/> <Column Name="PictureHeight"/> <Column Name="DatePictureTaken"/> <Column Name="ServerRedirectedURL"/> </Columns></property>
<property name="SampleData" type="string"><All_Results> <Result> <workid>1</workid> <rank>222</rank> <title>Title of document or web page</title> <author>Author of document or web page</author> <size>1025</size> <sitename>http://www.sample.com</sitename> <url>http://www.sample.com/folder/document.aspx</url> <imageurl>/_layouts/images/aspx16.gif</imageurl> <description>This is the summary of the document or web page. The summary is generated from the original document based on matches with query terms. In some cases, the summary is a description provided by the author.</description> <write>December 26, 2004</write> </Result></All_Results></property>
<property name="EnableDocumentPreviewWord" type="bool">True</property>
<property name="AutoRefreshInterval" type="int">60</property>
<property name="CharactersInSummary" type="int">185</property>
<property name="TitleUrl" type="string" />
<property name="RemoveDuplicates" type="bool">True</property>
<property name="Xsl" type="string">
<xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">&apos;</xsl:param>
<xsl:param name="ManualRefresh"></xsl:param>
<xsl:param name="FileName" />
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
<xsl:choose>
<xsl:when test="($ManualRefresh = 'True')">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<xsl:call-template name="dvt_1"/>
</td>
<td width="1%" class="ms-vb" valign="top">
<img src="/_layouts/images/staticrefresh.gif" id="ManualRefresh" border="0" onclick="javascript: {ddwrt:GenFireServerEvent('__cancel')}" alt="Click here to refresh the dataview."/>
</td>
</tr>
</table>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="dvt_1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/All_Results/Result"/>
<xsl:variable name="dvt_RowCount" select="count($Rows)"/>
<xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
<xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>
<xsl:choose>
<xsl:when test="$dvt_IsEmpty">
<xsl:call-template name="dvt_1.empty"/>
</xsl:when>
<xsl:otherwise>
<table border="0" width="100%" cellpadding="2" cellspacing="0">
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/></xsl:call-template>
</table>
</xsl:otherwise>
</xsl:choose></xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"/>
<xsl:for-each select="$Rows">
<xsl:call-template name="dvt_1.rowview" />
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<tr>
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">ms-alternating</xsl:attribute>
</xsl:if>
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<td class="ms-vb" width="1%" nowrap="nowrap">
<span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"></span>
</td>
</xsl:if>
<td class="ms-vb">
<a href="{url}"><xsl:value-of select="title" /></a>
</td>
</tr>
</xsl:template>
<xsl:template name="dvt_1.empty">
<xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable>
<table border="0" width="100%">
<tr>
<td class="ms-vb">
<xsl:value-of select="$dvt_ViewEmptyText"/>
</td>
</tr>
</table>
</xsl:template></xsl:stylesheet></property>
<property name="View" type="Microsoft.Office.Server.Search.WebControls.ResultsView, Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Modified_Date</property>
<property name="TitleIconImageUrl" type="string" />
<property name="EnableSimilarFind" type="bool">False</property>
<property name="Direction" type="direction">NotSet</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="ResultsPerPage" type="System.Int16, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">20</property>
<property name="ShowWithSampleData" type="bool">False</property>
<property name="Description" type="string">Displays the search results and the properties associated with them.</property>
<property name="EnableNicknames" type="bool">False</property>
<property name="AutoRefresh" type="bool">False</property>
<property name="IsLocationPeople" type="bool">False</property>
<property name="Location" type="string" />
<property name="NoDefaultStyle" type="string" />
<property name="ShowWindowsSearch" type="bool">True</property>
<property name="UseLocationVisualization" type="bool">False</property>
<property name="MoreResultsText" type="string">View more results »</property>
</properties>
</data>
</webPart>
</webParts>