none
How to apply security trimming to Dataview

    Question

  •  

    I have a publishing portal with several publishing sub-sites. These site make up many of my companies internal publications. However some of these publications are restricted to managers or supervisors only. I would like to have a single place on our main portal page that aggregates all of the publications together and performs security trimming based on weather the user has access to the sub-site. I have created a dataview that links all of the sources together, but if I try to restrict any one of the subsites I get the error "Access denied. You do not have permission to perform this action or access this resource." If a user has full permissions to see everything then the dataview works fine. Anyone know how I can security trim the dataview or perhaps security wrap multiple dataviews to restrict which one is shown based on security.
    Thursday, January 3, 2008 5:08 PM

Answers

  • Hi,

    The Content Query web part would handle the security trimming for you but I understand that you probably want to use the Data View because of the awesome flexibility over the design time experience.

    The Data View web part has even more features than thoes that are exposed through SharePoint Designer. You should try the CrossList query mode. See http://blogs.msdn.com/sharepointdesigner/archive/2007/04/24/spdatasource-and-rollups-with-the-data-view.aspx

    Regards,
    Ian
    http://www.wssdemo.com

     

    Thursday, January 3, 2008 7:40 PM
  • CQWP is not strictly limited to a single content type.  This article might help you if you're really stuck on your current approach:

     

    http://www.helloitsliam.com/archive/2007/09/09/MOSS2007%20%e2%80%93%20Content%20Query%20Web%20Part%20(Multiple%20Content%20Types).aspx

     

    --Paul Galvin, Conchango
      RSS @ http://feeds.feedburner.com/PaulGalvinsSharepointSpace
      Web site @ http://paulgalvin.spaces.live.com
    Wednesday, January 9, 2008 12:29 AM
  • Here is the code for my working, security trimming, dataview using CrossList Query mode on a SPDataSource tag. Below I will include some commments of things to note.

     

    Code Block

    <WebPartPages:DataFormWebPart runat="server" IsIncluded="True" NoDefaultStyle="TRUE" ViewFlag="0" ListName="{E41B316F-9DA8-4444-BA52-73DF6E0C2A7C}" Default="FALSE" DisplayName="Pages" __markuptype="vsattributemarkup" partorder="2" __WebPartId="{4E99E862-56AE-4813-8714-7E20B52207F6}" id="g_4e99e862_56ae_4813_8714_7e20b52207f6" pagesize="6" __AllowXSLTEditing="true" WebPart="true" Height="" Width="">
     <DataSources>
      <SharePointWebControls:SPDataSource
       runat="server"
       DataSourceMode="CrossList"
       UseInternalName="true"
       selectcommand="&lt;View&gt;&lt;Webs Scope=&quot;Recursive&quot;&gt;&lt;/Webs&gt;&lt;Lists&gt;&lt;List ID=&quot;4E7F3B7C-7988-4D3D-8627-8212CBAC272B&quot;&gt;&lt;/List&gt;&lt;List ID=&quot;D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6&quot;&gt;&lt;/List&gt;&lt;List ID=&quot;BD1D085C-ACBC-46FC-9BCC-139B4DBC3500&quot;&gt;&lt;/List&gt;&lt;/Lists&gt;&lt;View&gt;&lt;ViewFields&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;FieldRef Name=&quot;Title&quot;/&gt;&lt;FieldRef Name=&quot;Comments&quot;/&gt;&lt;FieldRef Name=&quot;PublishingStartDate&quot;/&gt;&lt;FieldRef Name=&quot;PublishingRollupImage&quot;/&gt;&lt;FieldRef Name=&quot;FileRef&quot; Type=&quot;&quot;/&gt;&lt;FieldRef Name=&quot;FileDirRef&quot;/&gt;&lt;FieldRef Name=&quot;FileLeafRef&quot;/&gt;&lt;FieldRef Name=&quot;PermMask&quot;/&gt;&lt;/ViewFields&gt;&lt;/View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Neq&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Welcome Page&lt;/Value&gt;&lt;/Neq&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;PublishingStartDate&quot; Ascending=&quot;FALSE&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;"
       id="Pages2">
      </SharePointWebControls:SPDataSource>
     </DataSources>
     <ParameterBindings>
      <ParameterBinding Name="ListID" Location="None" DefaultValue="E41B316F-9DA8-4444-BA52-73DF6E0C2A7C"/>
      <ParameterBinding Name="WebURL" Location="None" DefaultValue="{sitecollectionroot}"/>
      <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
      <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
      <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
      <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
      <ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
      <ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
     </ParameterBindings>
     <datafields>@ListId,ListId;@WebId,WebId;@ID,ID;@ContentType,ContentType;@Title,Title;@Comments,Comments;@PublishingStartDate,PublishingStartDate;@PublishingRollupImage,PublishingRollupImage;@FileRef,FileRef;@FileDirRef,FileDirRef;@FileLeafRef,FileLeafRef;@PermMask,PermMask;</datafields>
     <XSL>
      <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 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="dvt_firstrow">1</xsl:param>
       <xsl:param name="dvt_nextpagedata" />
       <xsl:variable name="dvt_1_automode">0</xsl:variable>
       <xsl:template match="/">
        <xsl:call-template name="dvt_1"/>
       </xsl:template>
       <xsl:template name="dvt_1.navigation">
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:param name="RowLimit"/>
        <xsl:param name="dvt_RowCount" />
        <xsl:param name="RealLastRow" />
        <xsl:variable name="PrevRow">
         <xsl:choose>
          <xsl:when test="$FirstRow - $RowLimit &lt; 1">1</xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$FirstRow - $RowLimit" />
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="LastRowValue">
         <xsl:choose>
          <xsl:when test="$LastRow &gt; $RealLastRow">
           <xsl:value-of select="$LastRow"></xsl:value-of>
          </xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$RealLastRow"></xsl:value-of>
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="NextRow">
         <xsl:value-of select="$LastRowValue + 1"></xsl:value-of>
        </xsl:variable>
        <td nowrap="" class="ms-paging" align="right">
         <xsl:if test="$dvt_firstrow &gt; 1" ddwrt:cf_ignore="1">
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent('dvt_firstrow={1}')" />
           ;</xsl:attribute>Start
          </a>
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$PrevRow,'}'))" />;
           </xsl:attribute>
           <img src="/_layouts/images/prev.gif" border="0" alt="Previous" />
          </a>
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
         </xsl:if>
         <xsl:value-of select="$FirstRow" />
         - <xsl:value-of select="$LastRowValue" />
         <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">&amp;nbsp;</xsl:text>
         <xsl:if test="$LastRowValue &lt; $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1">
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'}'))" />;
           </xsl:attribute>
           <img src="/_layouts/images/next.gif" border="0" alt="Next" />
          </a>
         </xsl:if>
        </td>
       </xsl:template>
       <xsl:template name="dvt_1">
        <xsl:variable name="dvt_StyleName">Commas</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
        <xsl:variable name="dvt_RowCount" select="count($Rows)" />
        <xsl:variable name="RowLimit" select="6" />
        <xsl:variable name="FirstRow" select="$dvt_firstrow" />
        <xsl:variable name="LastRow" >
         <xsl:choose>
          <xsl:when test="($FirstRow + $RowLimit - 1) &gt; $dvt_RowCount">
           <xsl:value-of select="$dvt_RowCount" />
          </xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$FirstRow + $RowLimit - 1" />
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
        <xsl:call-template name="dvt_1.body">
         <xsl:with-param name="Rows" select="$Rows[position() &gt;= $FirstRow and position() &lt;= $LastRow]"  />
         <xsl:with-param name="FirstRow" select="1" />
         <xsl:with-param name="LastRow" select="$dvt_RowCount" />
        </xsl:call-template>
        <xsl:call-template name="dvt_1.commandfooter">
         <xsl:with-param name="FirstRow" select="$FirstRow" />
         <xsl:with-param name="LastRow" select="$LastRow" />
         <xsl:with-param name="RowLimit" select="$RowLimit" />
         <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
         <xsl:with-param name="RealLastRow" select="number(ddwrt:NameChanged('',-100))" />
        </xsl:call-template>
       </xsl:template>
       <xsl:template name="dvt_1.body">
        <xsl:param name="Rows" />
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:for-each select="$Rows">
         <xsl:variable name="dvt_KeepItemsTogether" select="false()" />
         <xsl:variable name="dvt_HideGroupDetail" select="false()" />
         <xsl:if test="(position() &gt;= $FirstRow and position() &lt;= $LastRow) or $dvt_KeepItemsTogether">
          <xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
           <xsl:call-template name="dvt_1.rowview" />
          </xsl:if>
         </xsl:if>
        </xsl:for-each>
       </xsl:template>
       <xsl:template name="dvt_1.rowview">
      <p class="ms-vb">
       <b>
        <a href="../{substring-after(@FileRef,'#')}"><xsl:value-of select="@Title" /></a>
       </b>
       <br /><xsl:value-of select="@Comments" />
      <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
        <br /><span ddwrt:amkeyfield="" ddwrt:amkeyvalue="''" ddwrt:ammode="view" />
       </xsl:if>
        </p></xsl:template>
       <xsl:template name="dvt_1.commandfooter">
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:param name="RowLimit" />
        <xsl:param name="dvt_RowCount" />
        <xsl:param name="RealLastRow" />
        <table cellspacing="0" cellpadding="4" border="0" width="100%">
       <tr>
        <xsl:if test="$FirstRow &gt; 1 or $LastRow &lt; $dvt_RowCount">
         <xsl:call-template name="dvt_1.navigation">
          <xsl:with-param name="FirstRow" select="$FirstRow" />
          <xsl:with-param name="LastRow" select="$LastRow" />
          <xsl:with-param name="RowLimit" select="$RowLimit" />
          <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
          <xsl:with-param name="RealLastRow" select="$RealLastRow" />
         </xsl:call-template>
        </xsl:if>
         </tr>
      </table>
       </xsl:template>
       
      </xsl:stylesheet>
     </XSL>
    </WebPartPages:DataFormWebPart>


     


    I also will give you the unencoded select command from the SPDataSource Tag.

     

     

    Code Block

    <View>
     <Webs Scope="Recursive"></Webs>
     <Lists>
      <List ID="4E7F3B7C-7988-4D3D-8627-8212CBAC272B"></List>
      <List ID="D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6"></List>
      <List ID="BD1D085C-ACBC-46FC-9BCC-139B4DBC3500"></List>
     </Lists>
     <View>
      <ViewFields>
       <FieldRef Name="ContentType"/>
       <FieldRef Name="Title"/>
       <FieldRef Name="Comments"/>
       <FieldRef Name="PublishingStartDate"/>
       <FieldRef Name="PublishingRollupImage"/>
       <FieldRef Name="FileRef"/>
       <FieldRef Name="FileDirRef"/>
       <FieldRef Name="FileLeafRef"/>
       <FieldRef Name="PermMask"/>
      </ViewFields>
     </View>
     <Query>
      <Where>
       <Neq>
        <FieldRef Name="ContentType"/>
        <Value Type="Text">Welcome Page</Value>
       </Neq>
      </Where>
       <OrderBy>
        <FieldRef Name="PublishingStartDate" Ascending="FALSE"/>
       </OrderBy>
     </Query>
    </View>

     

     

    Things to note.

    • The tag <SharePointWebControlsTongue TiedPDataSource> attribute DataSourceMode must equal "CrossList".
    • The selectcommand attribute must be html encoded for special symbols.
    • The standard URL Path will not return correctly from the FileRef field it must be transformed using xsl. I found this blog to be helpful for that http://www.sharepointblogs.com/mkruger/archive/2007/06/26/free-sharepoint-dataview-tips.aspx (Tip #6).
    • For some reason paging broke when I implemented the crosslist and I had to fix it manually the corrected code is above.

    The code above aggregates three different page libraries with different security permission from three different subsites. There is a paging of 6 and each article title is hyperlinked to its article.

     

    Thanks,

    Josh

    Thursday, January 10, 2008 10:30 PM

All replies

  • Hi,

    The Content Query web part would handle the security trimming for you but I understand that you probably want to use the Data View because of the awesome flexibility over the design time experience.

    The Data View web part has even more features than thoes that are exposed through SharePoint Designer. You should try the CrossList query mode. See http://blogs.msdn.com/sharepointdesigner/archive/2007/04/24/spdatasource-and-rollups-with-the-data-view.aspx

    Regards,
    Ian
    http://www.wssdemo.com

     

    Thursday, January 3, 2008 7:40 PM
  • I have looked at the Content Query web part and it does handle security trimming, but it definantly takes away alot of options. However, the real problem is that it can display only one content type and since one of the publications that I am aggregating is an executives blog it doesn't work for me.

     

    Though it was that web part that made me assume that I could do this with ease. I have tested it with multiple folders within the same site that have different security permissions and the security trimming works but when I try to aggregate sources from subsites the dataview just fails with an Access denied error.

     

    Thanks,

    Josh

     

    Thursday, January 3, 2008 9:30 PM
  • Just in case it would help anyone to see what my current code looks like I've posted it below.

     

    Code Block
    <WebPartPages:DataFormWebPart runat="server" IsIncluded="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="0" Title="New Data Source" __markuptype="vsattributemarkup" __WebPartId="{620F473B-33B0-4274-9331-45936F3B8D1C}" id="g_620f473b_33b0_4274_9331_45936f3b8d1c" __AllowXSLTEditing="true" WebPart="true" Height="" Width="" pagesize="7">
     <DataSources>
      <SharePointWebControls:AggregateDataSource runat="server" IsSynchronous="false" id="New_x0020_Data_x0020_Source1">
       <sources>
        <SharePointWebControls:spdatasource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;">
         <SelectParameters>
          <asp:Parameter Name="ListID" DefaultValue="4E7F3B7C-7988-4D3D-8627-8212CBAC272B"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinsup/"/>
         </SelectParameters>
         <DeleteParameters>
          <asp:Parameter Name="ListID" DefaultValue="4E7F3B7C-7988-4D3D-8627-8212CBAC272B"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinsup/"/>
         </DeleteParameters>
         <UpdateParameters>
          <asp:Parameter Name="ListID" DefaultValue="4E7F3B7C-7988-4D3D-8627-8212CBAC272B"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinsup/"/>
         </UpdateParameters>
         <InsertParameters>
          <asp:Parameter Name="ListID" DefaultValue="4E7F3B7C-7988-4D3D-8627-8212CBAC272B"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinsup/"/>
         </InsertParameters>
        </SharePointWebControls:spdatasource>
        <SharePointWebControls:spdatasource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;">
         <SelectParameters>
          <asp:Parameter Name="ListID" DefaultValue="D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinmanag/"/>
         </SelectParameters>
         <DeleteParameters>
          <asp:Parameter Name="ListID" DefaultValue="D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinmanag/"/>
         </DeleteParameters>
         <UpdateParameters>
          <asp:Parameter Name="ListID" DefaultValue="D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinmanag/"/>
         </UpdateParameters>
         <InsertParameters>
          <asp:Parameter Name="ListID" DefaultValue="D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6"/>
          <asp:Parameter Name="WebURL" DefaultValue="/bulletinmanag/"/>
         </InsertParameters>
        </SharePointWebControls:spdatasource>
        <SharePointWebControls:spdatasource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;">
         <SelectParameters>
          <asp:Parameter Name="ListID" DefaultValue="BD1D085C-ACBC-46FC-9BCC-139B4DBC3500"/>
          <asp:Parameter Name="WebURL" DefaultValue="/commpub/"/>
         </SelectParameters>
         <DeleteParameters>
          <asp:Parameter Name="ListID" DefaultValue="BD1D085C-ACBC-46FC-9BCC-139B4DBC3500"/>
          <asp:Parameter Name="WebURL" DefaultValue="/commpub/"/>
         </DeleteParameters>
         <UpdateParameters>
          <asp:Parameter Name="ListID" DefaultValue="BD1D085C-ACBC-46FC-9BCC-139B4DBC3500"/>
          <asp:Parameter Name="WebURL" DefaultValue="/commpub/"/>
         </UpdateParameters>
         <InsertParameters>
          <asp:Parameter Name="ListID" DefaultValue="BD1D085C-ACBC-46FC-9BCC-139B4DBC3500"/>
          <asp:Parameter Name="WebURL" DefaultValue="/commpub/"/>
         </InsertParameters>
        </SharePointWebControls:spdatasource>
        <SharePointWebControls:spdatasource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;">
         <SelectParameters>
          <asp:Parameter Name="ListID" DefaultValue="D0EDEEC3-775C-4852-B14F-B26D2A0C22FE"/>
          <asp:Parameter Name="WebURL" DefaultValue="/jblog/"/>
         </SelectParameters>
         <DeleteParameters>
          <asp:Parameter Name="ListID" DefaultValue="D0EDEEC3-775C-4852-B14F-B26D2A0C22FE"/>
          <asp:Parameter Name="WebURL" DefaultValue="/jblog/"/>
         </DeleteParameters>
         <UpdateParameters>
          <asp:Parameter Name="ListID" DefaultValue="D0EDEEC3-775C-4852-B14F-B26D2A0C22FE"/>
          <asp:Parameter Name="WebURL" DefaultValue="/jblog/"/>
         </UpdateParameters>
         <InsertParameters>
          <asp:Parameter Name="ListID" DefaultValue="D0EDEEC3-775C-4852-B14F-B26D2A0C22FE"/>
          <asp:Parameter Name="WebURL" DefaultValue="/jblog/"/>
         </InsertParameters>
        </SharePointWebControls:spdatasource>
       </sources>
       <aggregate>
        <concat name="data source">
         <datasource name="Pages2" id="0" Type="SPDocLib"/>
         <datasource name="Pages" id="1" Type="SPDocLib"/>
         <datasource name="Pages3" id="2" Type="SPDocLib"/>
         <datasource name="Post" id="3" Type="SPList"/>
        </concat>
       </aggregate>
      </SharePointWebControls:AggregateDataSource>
     </DataSources>
     <ParameterBindings>
      <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
      <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
      <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
      <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
      <ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
     </ParameterBindings>
     <datafields>@_ModerationStatus,Approval Status;@_ModerationComments,Approver Comments;@FileLeafRef,Name (for use in forms);@Title,Title;@Comments,Description;@PublishingStartDate,Scheduling Start Date;@PublishingExpirationDate,Scheduling End Date;@PublishingContact,Contact;@PublishingContactEmail,Contact E-Mail Address;@PublishingContactName,Contact Name;@PublishingContactPicture,Contact Picture;@PublishingPageLayout,Page Layout;@PublishingRollupImage,Rollup Image;@Audience,Target Audiences;@ContentType,Content Type;@PublishingPageImage,Page Image;@PublishingPageContent,Page Content;@SummaryLinks,Summary Links;@ArticleByLine,Byline;@ArticleStartDate,Article Date;@PublishingImageCaption,Image Caption;@SummaryLinks2,Summary Links 2;@Parallel,Parallel Approval;@Company_x0020_Scope,Company Scope;@Page_x0020_Content_x0020_1,Page Content 1;@Page_x0020_Content_x0020_2,Page Content 2;@Page_x0020_Content_x0020_3,Page Content 3;@Page_x0020_Content_x0020_4,Page Content 4;@Page_x0020_Content_x0020_5,Page Content 5;@Page_x0020_Content_x0020_6,Page Content 6;@Page_x0020_Content_x0020_7,Page Content 7;@Page_x0020_Content_x0020_8,Page Content 8;@Page_x0020_Content_x0020_9,Page Content 9;@Content_x0020_Title,Content Title;@Content_x0020_Title_x0020_1,Content Title 1;@Content_x0020_Title_x0020_2,Content Title 2;@Content_x0020_Title_x0020_3,Content Title 3;@Content_x0020_Title_x0020_4,Content Title 4;@Content_x0020_Title_x0020_5,Content Title 5;@Content_x0020_Title_x0020_6,Content Title 6;@Content_x0020_Title_x0020_7,Content Title 7;@Content_x0020_Title_x0020_8,Content Title 8;@Content_x0020_Title_x0020_9,Content Title 9;@Section_x0020_Heading,Section Heading;@Section_x0020_Heading_x0020_1,Section Heading 1;@Section_x0020_Heading_x0020_2,Section Heading 2;@Section_x0020_Heading_x0020_3,Section Heading 3;@Section_x0020_Heading_x0020_4,Section Heading 4;@Section_x0020_Heading_x0020_5,Section Heading 5;@Section_x0020_Heading_x0020_6,Section Heading 6;@Section_x0020_Heading_x0020_7,Section Heading 7;@Section_x0020_Heading_x0020_8,Section Heading 8;@Section_x0020_Heading_x0020_9,Section Heading 9;@Volume_x0020_Number,Volume Number;@ID,ID;@Created,Created;@Author,Created By;@Modified,Modified;@Editor,Modified By;@_CopySource,Copy Source;@CheckoutUser,Checked Out To;@_CheckinComment,Check In Comment;@CheckedOutTitle,Checked Out To;@CheckedOutUserId,ID of the User who has the item Checked Out;@FileDirRef,Path;@FSObjType,Item Type;@HTML_x0020_File_x0020_Type,HTML File Type;@File_x0020_Type,File Type;@IsCheckedoutToLocal,Is Checked out to local;@_SourceUrl,Source Url;@_HasCopyDestinations,Has Copy Destinations;@ContentTypeId,Content Type ID;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@File_x0020_Size,File Size;@_UIVersionString,Version;@ParentVersionString,Source Version (Converted Document);@ParentLeafName,Source Name (Converted Document);@TemplateUrl,Template Link;@Page_x0020_Image_x0020_1,Page Image 1;@Article_x0020_Source,Article Source;@Article_x0020_Source_x0020_Url,Article Source Url;@Body,Body;@NumComments,# Comments;@PostCategory,Category;@PublishedDate,Published;@Proofrea,Proofreading Workflow;@Lead,Lead;@Attachments,Attachments;</datafields>
     <XSL>         
      <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A< A>>" xmlns:x="http://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A< A>>" xmlns:d="http://schemas.microsoft.com/sharepoint/dsphttp://schemas.microsoft.com/sharepoint/dsp">http://schemas.microsoft.com/sharepoint/dsp</A< A>>" xmlns:agg="http://schemas.microsoft.com/sharepoint/aggregatesourcehttp://schemas.microsoft.com/sharepoint/aggregatesource">http://schemas.microsoft.com/sharepoint/aggregatesource</A< A>>" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtimehttp://schemas.microsoft.com/WebParts/v2/DataView/runtime">http://schemas.microsoft.com/WebParts/v2/DataView/runtime</A< A>>" xmlns:asp="http://schemas.microsoft.com/ASPNET/20http://schemas.microsoft.com/ASPNET/20">http://schemas.microsoft.com/ASPNET/20</A< A>>" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designerhttp://schemas.microsoft.com/WebParts/v2/DataView/designer">http://schemas.microsoft.com/WebParts/v2/DataView/designer</A< A>>" xmlns:xsl="http://www.w3.org/1999/XSL/Transformhttp://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</A< A>>" 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="dvt_firstrow">1</xsl:param>
      <xsl:param name="dvt_nextpagedata" />
      <xsl:variable name="dvt_1_automode">0</xsl:variable>
       <xsl:template match="/">
        <xsl:call-template name="dvt_1"/>
       </xsl:template>
       <xsl:template name="dvt_1">
        <xsl:variable name="dvt_StyleName">Commas</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[normalize-space(@_ModerationStatus) = 'Approved' and normalize-space(@FileLeafRef) != 'default.aspx']" />
        <xsl:variable name="dvt_RowCount" select="count($Rows)" />
        <xsl:variable name="RowLimit" select="7" />
        <xsl:variable name="FirstRow" select="$dvt_firstrow" />
        <xsl:variable name="LastRow">
         <xsl:choose>
          <xsl:when test="($FirstRow + $RowLimit - 1) &gt; $dvt_RowCount"><xsl:value-of select="$dvt_RowCount" /></xsl:when>
          <xsl:otherwise><xsl:value-of select="$FirstRow + $RowLimit - 1" /></xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0 or $RowLimit = 0" />
        <xsl:call-template name="dvt_1.body">
         <xsl:with-param name="Rows" select="$Rows" />
         <xsl:with-param name="FirstRow" select="$FirstRow" />
         <xsl:with-param name="LastRow" select="$LastRow" />
        </xsl:call-template>
        <xsl:call-template name="dvt_1.commandfooter">
         <xsl:with-param name="FirstRow" select="$FirstRow" />
         <xsl:with-param name="LastRow" select="$LastRow" />
         <xsl:with-param name="RowLimit" select="$RowLimit" />
         <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
         <xsl:with-param name="RealLastRow" select="number(ddwrt:NameChanged('',-100))" />
        </xsl:call-template>
       </xsl:template>
       <xsl:template name="dvt_1.body">
        <xsl:param name="Rows" />
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:for-each select="$Rows">
         <xsl:sort select="@PublishingStartDate|@PublishedDate" order="descending" />
         <xsl:variable name="dvt_KeepItemsTogether" select="false()" />
         <xsl:variable name="dvt_HideGroupDetail" select="false()" />
         <xsl:if test="(position() &gt;= $FirstRow and position() &lt;= $LastRow) or $dvt_KeepItemsTogether">
          <xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
           <xsl:call-template name="dvt_1.rowview" />
          </xsl:if>
         </xsl:if>
        </xsl:for-each>
       </xsl:template>
       <xsl:template name="dvt_1.rowview">
        <p class="ms-vb">
         <b>
          <xsl:if test="@ContentType = 'Post'" ddwrt:cf_ignore="1">
           <a href="
    http://sharenet/jblog/Lists/Posts/Post.aspx?ID={@Permalink}">
            <xsl:value-of'>http://sharenet/jblog/Lists/Posts/Post.aspx?ID={@Permalink">http://sharenet/jblog/Lists/Posts/Post.aspx?ID={@Permalink}">
            <xsl:value-of select="@Title" />
           </a>
          </xsl:if>
          <xsl:if test="@ContentType != 'Post'" ddwrt:cf_ignore="1">
           <a href="{@FileRef}"><xsl:value-of select="@Title" /></a>
          </xsl:if>         
         </b>
         <br />
         <xsl:value-of select="@Comments|@Lead" />
         <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
          <br />
          <span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view" />
         </xsl:if>
        </p>
       </xsl:template>
       <xsl:template name="dvt_1.commandfooter">
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:param name="RowLimit" />
        <xsl:param name="dvt_RowCount" />
        <xsl:param name="RealLastRow" />
        <table cellspacing="0" cellpadding="4" border="0" width="100%">
         <tr>
          <xsl:if test="$FirstRow &gt; 1 or $LastRow &lt; $dvt_RowCount">
           <xsl:call-template name="dvt_1.navigation">
            <xsl:with-param name="FirstRow" select="$FirstRow" />
            <xsl:with-param name="LastRow" select="$LastRow" />
            <xsl:with-param name="RowLimit" select="$RowLimit" />
            <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
            <xsl:with-param name="RealLastRow" select="$RealLastRow" />
           </xsl:call-template>
          </xsl:if>
         </tr>
        </table>
       </xsl:template>
       <xsl:template name="dvt_1.navigation">
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:param name="RowLimit" />
        <xsl:param name="dvt_RowCount" />
        <xsl:param name="RealLastRow" />
        <xsl:variable name="PrevRow">
         <xsl:choose>
          <xsl:when test="$FirstRow - $RowLimit &lt; 1">1</xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$FirstRow - $RowLimit" />
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="LastRowValue">
         <xsl:choose>
          <xsl:when test="$LastRow &gt; $RealLastRow">
           <xsl:value-of select="$LastRow"></xsl:value-of>
          </xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$RealLastRow"></xsl:value-of>
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="NextRow">
         <xsl:value-of select="$LastRowValue + 1"></xsl:value-of>
        </xsl:variable>
        <td nowrap="" class="ms-paging" align="right">
         <xsl:if test="$dvt_firstrow &gt; 1" ddwrt:cf_ignore="1">
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent('dvt_firstrow={1}')" />;</xsl:attribute>
          Start</a>
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$PrevRow,'}'))" />;</xsl:attribute>
           <img src="http://sharenet/_layouts/images/prev.gifhttp://sharenet/_layouts/images/prev.gif">http://sharenet/_layouts/images/prev.gif</A< A>>" border="0" alt="Previous" />
          </a>
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
         </xsl:if>
         <xsl:value-of select="$FirstRow" />
          - <xsl:value-of select="$LastRowValue" />
         <xsl:text xmlns:ddwrt="
    http://schemas.microsoft.com/WebParts/v2/DataView/runtimehttp://schemas.microsoft.com/WebParts/v2/DataView/runtime">http://schemas.microsoft.com/WebParts/v2/DataView/runtime</A< A>>" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;</xsl:text>
         <xsl:if test="$LastRowValue &lt; $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1">
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'}'))" />;</xsl:attribute>
           <img src="
    http://sharenet/_layouts/images/next.gifhttp://sharenet/_layouts/images/next.gif">http://sharenet/_layouts/images/next.gif</A< A>>" border="0" alt="Next" />
          </a>
         </xsl:if>
        </td>
       </xsl:template>
      </xsl:stylesheet> 
     </XSL>
    </WebPartPages:DataFormWebPart>

     

     


     

     

     

    Friday, January 4, 2008 6:08 PM
  • CQWP is not strictly limited to a single content type.  This article might help you if you're really stuck on your current approach:

     

    http://www.helloitsliam.com/archive/2007/09/09/MOSS2007%20%e2%80%93%20Content%20Query%20Web%20Part%20(Multiple%20Content%20Types).aspx

     

    --Paul Galvin, Conchango
      RSS @ http://feeds.feedburner.com/PaulGalvinsSharepointSpace
      Web site @ http://paulgalvin.spaces.live.com
    Wednesday, January 9, 2008 12:29 AM
  • Thanks for the responses Paul and Ian.

     

    Paul: That is a great post on how to extend the functionality of the Content Query Web Part thanks for that. That post actually helped me figure out how to take Ian's post to the next step.

     

    Ian: The blog you pointed me to took me down a long road but it finally paid off. It appears, that blog, and only a handful of other sources even know what CrossList Query Mode is. After a lot of research and some trial and error I was able to get the cross list to work with security trimming. I haven't added the blog publications back into the code yet but it should be pretty straight forward from where I am now.

     

    I will post the final version of the code in a separate reply for others to benefit from.

     

    Thanks,

    Josh

    Thursday, January 10, 2008 10:00 PM
  • Here is the code for my working, security trimming, dataview using CrossList Query mode on a SPDataSource tag. Below I will include some commments of things to note.

     

    Code Block

    <WebPartPages:DataFormWebPart runat="server" IsIncluded="True" NoDefaultStyle="TRUE" ViewFlag="0" ListName="{E41B316F-9DA8-4444-BA52-73DF6E0C2A7C}" Default="FALSE" DisplayName="Pages" __markuptype="vsattributemarkup" partorder="2" __WebPartId="{4E99E862-56AE-4813-8714-7E20B52207F6}" id="g_4e99e862_56ae_4813_8714_7e20b52207f6" pagesize="6" __AllowXSLTEditing="true" WebPart="true" Height="" Width="">
     <DataSources>
      <SharePointWebControls:SPDataSource
       runat="server"
       DataSourceMode="CrossList"
       UseInternalName="true"
       selectcommand="&lt;View&gt;&lt;Webs Scope=&quot;Recursive&quot;&gt;&lt;/Webs&gt;&lt;Lists&gt;&lt;List ID=&quot;4E7F3B7C-7988-4D3D-8627-8212CBAC272B&quot;&gt;&lt;/List&gt;&lt;List ID=&quot;D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6&quot;&gt;&lt;/List&gt;&lt;List ID=&quot;BD1D085C-ACBC-46FC-9BCC-139B4DBC3500&quot;&gt;&lt;/List&gt;&lt;/Lists&gt;&lt;View&gt;&lt;ViewFields&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;FieldRef Name=&quot;Title&quot;/&gt;&lt;FieldRef Name=&quot;Comments&quot;/&gt;&lt;FieldRef Name=&quot;PublishingStartDate&quot;/&gt;&lt;FieldRef Name=&quot;PublishingRollupImage&quot;/&gt;&lt;FieldRef Name=&quot;FileRef&quot; Type=&quot;&quot;/&gt;&lt;FieldRef Name=&quot;FileDirRef&quot;/&gt;&lt;FieldRef Name=&quot;FileLeafRef&quot;/&gt;&lt;FieldRef Name=&quot;PermMask&quot;/&gt;&lt;/ViewFields&gt;&lt;/View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Neq&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Welcome Page&lt;/Value&gt;&lt;/Neq&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;PublishingStartDate&quot; Ascending=&quot;FALSE&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;"
       id="Pages2">
      </SharePointWebControls:SPDataSource>
     </DataSources>
     <ParameterBindings>
      <ParameterBinding Name="ListID" Location="None" DefaultValue="E41B316F-9DA8-4444-BA52-73DF6E0C2A7C"/>
      <ParameterBinding Name="WebURL" Location="None" DefaultValue="{sitecollectionroot}"/>
      <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
      <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
      <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
      <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
      <ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
      <ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
     </ParameterBindings>
     <datafields>@ListId,ListId;@WebId,WebId;@ID,ID;@ContentType,ContentType;@Title,Title;@Comments,Comments;@PublishingStartDate,PublishingStartDate;@PublishingRollupImage,PublishingRollupImage;@FileRef,FileRef;@FileDirRef,FileDirRef;@FileLeafRef,FileLeafRef;@PermMask,PermMask;</datafields>
     <XSL>
      <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 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="dvt_firstrow">1</xsl:param>
       <xsl:param name="dvt_nextpagedata" />
       <xsl:variable name="dvt_1_automode">0</xsl:variable>
       <xsl:template match="/">
        <xsl:call-template name="dvt_1"/>
       </xsl:template>
       <xsl:template name="dvt_1.navigation">
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:param name="RowLimit"/>
        <xsl:param name="dvt_RowCount" />
        <xsl:param name="RealLastRow" />
        <xsl:variable name="PrevRow">
         <xsl:choose>
          <xsl:when test="$FirstRow - $RowLimit &lt; 1">1</xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$FirstRow - $RowLimit" />
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="LastRowValue">
         <xsl:choose>
          <xsl:when test="$LastRow &gt; $RealLastRow">
           <xsl:value-of select="$LastRow"></xsl:value-of>
          </xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$RealLastRow"></xsl:value-of>
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="NextRow">
         <xsl:value-of select="$LastRowValue + 1"></xsl:value-of>
        </xsl:variable>
        <td nowrap="" class="ms-paging" align="right">
         <xsl:if test="$dvt_firstrow &gt; 1" ddwrt:cf_ignore="1">
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent('dvt_firstrow={1}')" />
           ;</xsl:attribute>Start
          </a>
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$PrevRow,'}'))" />;
           </xsl:attribute>
           <img src="/_layouts/images/prev.gif" border="0" alt="Previous" />
          </a>
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
         </xsl:if>
         <xsl:value-of select="$FirstRow" />
         - <xsl:value-of select="$LastRowValue" />
         <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">&amp;nbsp;</xsl:text>
         <xsl:if test="$LastRowValue &lt; $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1">
          <a>
           <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'}'))" />;
           </xsl:attribute>
           <img src="/_layouts/images/next.gif" border="0" alt="Next" />
          </a>
         </xsl:if>
        </td>
       </xsl:template>
       <xsl:template name="dvt_1">
        <xsl:variable name="dvt_StyleName">Commas</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
        <xsl:variable name="dvt_RowCount" select="count($Rows)" />
        <xsl:variable name="RowLimit" select="6" />
        <xsl:variable name="FirstRow" select="$dvt_firstrow" />
        <xsl:variable name="LastRow" >
         <xsl:choose>
          <xsl:when test="($FirstRow + $RowLimit - 1) &gt; $dvt_RowCount">
           <xsl:value-of select="$dvt_RowCount" />
          </xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$FirstRow + $RowLimit - 1" />
          </xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
        <xsl:call-template name="dvt_1.body">
         <xsl:with-param name="Rows" select="$Rows[position() &gt;= $FirstRow and position() &lt;= $LastRow]"  />
         <xsl:with-param name="FirstRow" select="1" />
         <xsl:with-param name="LastRow" select="$dvt_RowCount" />
        </xsl:call-template>
        <xsl:call-template name="dvt_1.commandfooter">
         <xsl:with-param name="FirstRow" select="$FirstRow" />
         <xsl:with-param name="LastRow" select="$LastRow" />
         <xsl:with-param name="RowLimit" select="$RowLimit" />
         <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
         <xsl:with-param name="RealLastRow" select="number(ddwrt:NameChanged('',-100))" />
        </xsl:call-template>
       </xsl:template>
       <xsl:template name="dvt_1.body">
        <xsl:param name="Rows" />
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:for-each select="$Rows">
         <xsl:variable name="dvt_KeepItemsTogether" select="false()" />
         <xsl:variable name="dvt_HideGroupDetail" select="false()" />
         <xsl:if test="(position() &gt;= $FirstRow and position() &lt;= $LastRow) or $dvt_KeepItemsTogether">
          <xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
           <xsl:call-template name="dvt_1.rowview" />
          </xsl:if>
         </xsl:if>
        </xsl:for-each>
       </xsl:template>
       <xsl:template name="dvt_1.rowview">
      <p class="ms-vb">
       <b>
        <a href="../{substring-after(@FileRef,'#')}"><xsl:value-of select="@Title" /></a>
       </b>
       <br /><xsl:value-of select="@Comments" />
      <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
        <br /><span ddwrt:amkeyfield="" ddwrt:amkeyvalue="''" ddwrt:ammode="view" />
       </xsl:if>
        </p></xsl:template>
       <xsl:template name="dvt_1.commandfooter">
        <xsl:param name="FirstRow" />
        <xsl:param name="LastRow" />
        <xsl:param name="RowLimit" />
        <xsl:param name="dvt_RowCount" />
        <xsl:param name="RealLastRow" />
        <table cellspacing="0" cellpadding="4" border="0" width="100%">
       <tr>
        <xsl:if test="$FirstRow &gt; 1 or $LastRow &lt; $dvt_RowCount">
         <xsl:call-template name="dvt_1.navigation">
          <xsl:with-param name="FirstRow" select="$FirstRow" />
          <xsl:with-param name="LastRow" select="$LastRow" />
          <xsl:with-param name="RowLimit" select="$RowLimit" />
          <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
          <xsl:with-param name="RealLastRow" select="$RealLastRow" />
         </xsl:call-template>
        </xsl:if>
         </tr>
      </table>
       </xsl:template>
       
      </xsl:stylesheet>
     </XSL>
    </WebPartPages:DataFormWebPart>


     


    I also will give you the unencoded select command from the SPDataSource Tag.

     

     

    Code Block

    <View>
     <Webs Scope="Recursive"></Webs>
     <Lists>
      <List ID="4E7F3B7C-7988-4D3D-8627-8212CBAC272B"></List>
      <List ID="D43D4DBA-6F42-4010-8BD1-7BC8E3B238F6"></List>
      <List ID="BD1D085C-ACBC-46FC-9BCC-139B4DBC3500"></List>
     </Lists>
     <View>
      <ViewFields>
       <FieldRef Name="ContentType"/>
       <FieldRef Name="Title"/>
       <FieldRef Name="Comments"/>
       <FieldRef Name="PublishingStartDate"/>
       <FieldRef Name="PublishingRollupImage"/>
       <FieldRef Name="FileRef"/>
       <FieldRef Name="FileDirRef"/>
       <FieldRef Name="FileLeafRef"/>
       <FieldRef Name="PermMask"/>
      </ViewFields>
     </View>
     <Query>
      <Where>
       <Neq>
        <FieldRef Name="ContentType"/>
        <Value Type="Text">Welcome Page</Value>
       </Neq>
      </Where>
       <OrderBy>
        <FieldRef Name="PublishingStartDate" Ascending="FALSE"/>
       </OrderBy>
     </Query>
    </View>

     

     

    Things to note.

    • The tag <SharePointWebControlsTongue TiedPDataSource> attribute DataSourceMode must equal "CrossList".
    • The selectcommand attribute must be html encoded for special symbols.
    • The standard URL Path will not return correctly from the FileRef field it must be transformed using xsl. I found this blog to be helpful for that http://www.sharepointblogs.com/mkruger/archive/2007/06/26/free-sharepoint-dataview-tips.aspx (Tip #6).
    • For some reason paging broke when I implemented the crosslist and I had to fix it manually the corrected code is above.

    The code above aggregates three different page libraries with different security permission from three different subsites. There is a paging of 6 and each article title is hyperlinked to its article.

     

    Thanks,

    Josh

    Thursday, January 10, 2008 10:30 PM
  • This thread might be very old but it saved me a TON of time.

     

    Like Josh, I found that using Crosslist with a DVWP breaks paging.  The reason, as far as I can tell, is because the standard paging with the List mode paginates using the SPDataSource.  Where the crosslist will return all items and ignores those parameters.

    I used Josh's XSL (just the 2 spots where he modified it) to enable paging on my DVWP and it worked perfectly.

    In 4 hours of searching, this was the only place I saw a specific mention that using CrossList on a DVWP will break paging and it has to be fixed using XSL.

    Edit:I wanted to add that all of this applies to SP 2010 as that is where I am using this code.

    Tuesday, September 21, 2010 6:49 PM
  • Hi All,

    I was struggling with this and tried a different approach (because I only had one list - and I didn't need the crosslist query)

    Here is what worked for me --I tried wrapping it with a < SharePointWebControls:SPSecurityTrimmedControl > control - it doesnt' seem to work when you put it around the webpart if it's inside of a webpart zone HOWEVER- I did get it to work if I take the wp out of the zone. So if thats acceptable for you - and you only have one list - you might find this technique a little more quick and dirty

    btw - here is another post that I found useful in this endeavor - on End User SharePoint (you might need to login to see it)
    http://www.endusersharepoint.com/STP/viewtopic.php?f=14&t=116&start=10 

    • Edited by paisleygo Thursday, October 7, 2010 10:32 PM why is my email address my user name!?
    Thursday, October 7, 2010 10:31 PM