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
4 Comments