Adding hyperlink and folders to links list in onet.xml using CAML

Often you may want to create predefined html links in your SharePoint site along with your custom site definition. An example of this is the initial announcement you always get when you create a new team site: "Get Started with Windows SharePoint Services!". Creating items in Announcements list in the onet.xml file is pretty straight forward but to create html links in a links list you would have to use the following format: <Field Type="URL" Name="URL">http://<url>,<description></Field> An example of a predefined links to google is as follows:

<Data>
    <Rows>
        <Row>
            <Field Type="URL" Name="URL">http://www.google.com, Google search</Field>
            <Field Type="Node" Name="Comments">Navigate to Google Site</Field>
        </Row>
    </Rows>
</Data>

Seems easy enough once you get the syntax right, how about something more fancy like adding folders? The following is an example of the syntax for adding a folder using CAML in onet.xml

<Data>
    <Rows>
        <Row>
             <Field Name='ContentTypeId'>0x0120</Field>
             <Field Name='FSObjType'>1</Field>
             <Field Name='Title'>Folder1</Field>
             <Field Name='LinkTitle'>Folder1</Field>
         </Row>
    </Rows>
</Data>

As can be seen, CAML can be a pretty powerful tool although at times rather cryptic, a while ago I saw a presentation by Eric Shupps (SharePoint MVP, www.sharepointcowboy.com - american cowboy rather than a dodgy British cowboy ;) he mentioned several SharePoint "Emoticons" like 0;# _x0020, -1001 and ows_ which if you develop for SharePoint you know what it's all about - nice to see someone come up with a SharePoint joke like this :)

 

 

posted @ Monday, August 25, 2008 11:57 AM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 2 and 2 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910