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 :)

 

 

«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456