How to Aggregate List Items Across Sites with Url?

Below is my sample script to pull all blog posts on the site collection.

I  am having trouble providing the url of each item when using the CreateSPSiteDataQuery

 

## Setup site data query inputs
#set( $viewFieldsXml = "<FieldRef Name='FileRef' /><FieldRef Name='EncodedAbsUrl' /><FieldRef Name='FileDirRef' /><FieldRef Name='Title'/><FieldRef Name='Created' /><FieldRef Name='Author' /><FieldRef Name='Modified' /><FieldRef Name='Editor' /><FieldRef Name='PostCategory' />" )
#set( $listsXml = "<Lists ServerTemplate='301' />" )
#set( $websXml = "<Webs Scope='SiteCollection'/>" )
##set( $queryCaml = "<Where><IsNotNull><FieldRef Name='PostCategory' /></IsNotNull></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>" )
#set( $queryCaml = "<Where><Gt><FieldRef Name='Modified' Type='DateTime' /><Value Type='DateTime'><Today OffsetDays='-30' /></Value></Gt></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>")
 
## Create the site data query   
#set( $siteDataQuery = $SPUtility.CreateSPSiteDataQuery($viewFieldsXml, $listsXml, $websXml, $queryCaml, 10) )
 
## Execute the site data query
#set( $dataTable = $web.GetSiteData($siteDataQuery) )

 
#foreach($dataRow in $dataTable.Rows)
  #beforeall
    <table class="ms-listviewtable" cellpadding="3" cellspacing="0" border="0" width="100%">
      <tr class="ms-viewheadertr">
 <th class="ms-vh2-nofilter"></th>
        <th class="ms-vh2-nofilter">Categories</th>

        <th class="ms-vh2-nofilter">Title</th>
        <th class="ms-vh2-nofilter">Created</th>
        <th class="ms-vh2-nofilter">Author</th>
        <th class="ms-vh2-nofilter">Modified</th>
        <th class="ms-vh2-nofilter">Editor</th>
      </tr>
  #odd
      <tr class="">
  #even
      <tr class="ms-alternating">
  #each
 <td class="ms-vb2"><img src="/_layouts/images/STS_ListItem16.gif" /></td>
        <td class="ms-vb2">
  #set ( $Category = $Expressions.Split($dataRow.get_item("PostCategory"), "#") )
  $Strings.Format("$Category.get(1)")
 </td>
        <td class="ms-vb2">
  #set ( $FileRef = $Expressions.Split($dataRow.get_item("FileRef"), "#") )
  $Strings.Format("$FileRef.get(1)")

 $dataRow.get_item("Title")</td>
        <td class="ms-vb2">$dataRow.get_item("Created")</td>
        <td class="ms-vb2">
  #set ( $Author= $Expressions.Split($dataRow.get_item("Author"), "#") )
  $Strings.Format("$Author.get(1)")
 </td>
        <td class="ms-vb2">$dataRow.get_item("Modified")</td>
        <td class="ms-vb2">
  #set ( $Editor= $Expressions.Split($dataRow.get_item("Editor"), "#") )
  $Strings.Format("$Editor.get(1)")
 </td>
  #after
      </tr>
  #afterall
    </table>
  #nodata
    No KB Found
#end

 


 

Have more questions? Submit a request

4 Comments

  • 0
    Avatar
    Permanently deleted user

    Denzil,

    I'm not sure I fully understand your issue. It sounds like you are not able to pull the URL from the DataTable returned from the GetSiteData query. Is this correct?

     

     

  • 0
    Avatar
    Fernandes, Denzil

    Correct.... here is what I am temporarily doing to create the URL to the Blog Post...

    $site.url/$Strings.Format("$FileDirRef.get(1)")/Post.aspx?ID=$dataRow.get_item("ID")"

     

    Can't see how in the aggreate query to specify the displayform url

  • 0
    Avatar
    Fernandes, Denzil

    Here is how you do it....

    ## Get display url information
    #set( $sourceUrlEncoded = $HttpUtility.UrlEncode($request.RawUrl) )
    #set( $displayForm = $list.Forms.get_item($PAGETYPE_PAGE_DISPLAYFORM) )

     

    I get i need my display form to bind the list , but i couldnt find any samples where u have dont something like this on the help pages for datazoom

  • 0
    Avatar
    Permanently deleted user

    Denzil,

    We have similar code on our Get List Items by CAML sample....

    (Get List Items By CAML)
    http://help.sharepointsolutions.com/products/DataZoom/Samples_GetListItemsByCAML.html

    You can also find more complex examples on our script libary...

    (Data Zoom Script Library)
    http://www.siafoo.net/group/115

Please sign in to leave a comment.