Project and List Properties Available from CAML

When you are building a DVWP in SharePoint, there are some project (Web site) and list properties that are available to you directly from CAML that aren’t well-documented, which you can use if you request them directly.  For instance, if you add the following to your CAML <ListProperty Name=”Title” /><ProjectProperty Name=”Title” />, the titles of the project and list are available to you:

<xsl:value-of select=”@ListProperty.Title” />
<xsl:value-of select=”@ProjectProperty.Title” />

These properties are especially useful when you build CrossList DVWPs in order to build up links to items and to display information about them on the page.

Here’s an actual example from a project I worked on:

&lt;View&gt;&lt;Webs Scope="SiteCollection"&gt;&lt;/Webs&gt;&lt;Lists ServerTemplate="104"&gt;&lt;/Lists&gt;&lt;Query/&gt;&lt;ViewFields&gt;&lt;ProjectProperty Name="Title"/&gt;&lt;FieldRef Name="ID"/&gt;&lt;FieldRef Name="Title"/&gt;&lt;FieldRef Name="Body"/&gt;&lt;FieldRef Name="FileDirRef"/&gt;&lt;FieldRef Name="Created"/&gt;&lt;FieldRef Name="Author"/&gt;&lt;FieldRef Name="Expires"/&gt;&lt;FieldRef Name="PermMask"/&gt;&lt;FieldRef Name="ShowOnRootPage"/&gt;&lt;/ViewFields&gt;&lt;/View&gt;

and again in “English”:

<View>
  <Webs Scope="SiteCollection"></Webs>
  <Lists ServerTemplate="104"></Lists>
  <Query/>
  <ViewFields>
    <ProjectProperty Name="Title"/>
    <FieldRef Name="ID"/>
    <FieldRef Name="Title"/>
    <FieldRef Name="Body"/>
    <FieldRef Name="FileDirRef"/>
    <FieldRef Name="Created"/>
    <FieldRef Name="Author"/>
    <FieldRef Name="Expires"/>
    <FieldRef Name="PermMask"/>
    <FieldRef Name="ShowOnRootPage"/>
  </ViewFields>
</View>

ProjectProperty.Property Value
A string that contains the name of a project property listed in the following table.

Name Value
BlogCategoryTitle Category of the current post item.
BlogPostTitle Title of the current post item.
Description Description of the current Web site.
RecycleBinEnabled 1 if the recycle bin is enabled; otherwise, 0.
SiteOwnerName User name of the owner for the current site collection.
SiteUrl Full URL of the current site collection.
Title Title of the current Web site.
Url Full URL of the current Web site.

See ProjectProperty.Property Property for the original MSDN article.

ListProperty.Property Value
A string that contains the name of a property listed in the following table.

Name Value
Created Date and time the list was created.
DefaultViewUrl Server-relative URL of the default list view.
Description Description of the list.
EnableSyndication true if RSS syndication is enabled for the list; otherwise, false.
ItemCount Number of items in the list.
LinkTitle Title linked to list.
MajorVersionLimit For a document library that uses version control with major versions only, maximum number of major versions allowed for items.
MajorWithMinorVersionsLimit For a document library that uses version control with both major and minor versions, maximum number of major versions allowed for items.
RelativeFolderPath Site-relative URL for the list.
Title Title of the list.
ViewSelector View selector with links to views for the list.

See ListProperty.Property Property for the original MSDN article.

Similar Posts

29 Comments

  1. Hi Marc, how would I get this value to create the object below?
    SPSiteDataQuery allItemsSiteQuery = new SPSiteDataQuery();
    allItemsSiteQuery.RowLimit = (uint)rowLimit;
    allItemsSiteQuery.ViewFields = “” +
    “” +
    “” +
    “” +
    “” +
    “” +
    “” +
    “” +
    “” +
    “”;
    allItemsSiteQuery.Lists = “”;
    allItemsSiteQuery.Webs = “”;
    allItemsSiteQuery.Query = string.Format(“{0}”, ArticleContentTypeId);
    res = currentWeb.GetSiteData(allItemsSiteQuery).Rows.Cast().Select(row => new Actu(
    int.Parse(row[“ID”] as string),
    row[“Title”] as string,
    TryGetShortDateString(row[“Modified”] as string),
    row[“PublishingPageImage”] as string,
    row[“PublishingImageCaption”] as string,
    row[“Comments”] as string,
    HERE >>>>>>>>>> Title of Site where the page is… as string,
    HERE >>>>>>>>>> Url of Site where the page is…as string,
    row[“Actus_surtitre”] as string,
    row[“FileRef”] as string
    )).ToList();

    thanks

    1. Renato:

      As you can see, your code didn’t come through very well, but this post is about retrieving the site and list properties in CAML. I don’t think that’s what you are trying to do.

      M.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.