1 is the lonliest number

SharePoint. Some days you love it. Some days you hate it. Today is my hate day.

Site definitions are a pretty cool thing in that you can create a whole bunch of stuff for a user without lifting a finger. In ONET.XML you can create new lists in the <Configuration> tag. So go ahead and create a bunch of document libraries like this:

<Configurations>
<Configuration ID="0" Name="Default
">
<Lists>
<List Title="Document Library 1" Url="Document Library 1" Type="101"/>
<List Title="Document Library 2" Url="Document Library 2" Type="101"/>
<List Title="Document Library 3" Url="Document Library 3" Type="101
"/>
<List Title="Document Library 4" Url="Document Library 4" Type="101
"/>
<List Title="Document Library 5" Url="Document Library 5" Type="101
"/>
</Lists
>
</Configuration>
</Configurations>

Great. You now have 5 brand new unique Document Libraries, all with their own paths that you can add documents into. With ONET.XML you can also add these Document Libraries to a page automatically so we do this:

<Modules>
<Module Name="Default" Url="" Path
="">
<File Url="default.aspx" NavBarHome="True
">
<View List="101" BaseViewID="0" WebPartZoneID="Footer"/>
</File>
</Module
>
</Modules>

Awesome. Your Document Library is now smack in the Web Part Zone named Footer on your home page. Hmmm. Which document library? You only got to specify List="101". But now you're saying that you have not 1 but 5 of these things. Therein lies the rub. Just how do you get the second one on the page? And the third? Me little brain thought I would be clever and try this:

<Modules>
<Module Name="Default" Url="" Path
="">
<File Url="default.aspx" NavBarHome="True
">
<View List="101" BaseViewID="0" WebPartZoneID="Footer" Url="Document Library 1" />
<View List="101" BaseViewID="0" WebPartZoneID="Footer" Url="Document Library 2" />
<View List="101" BaseViewID="0" WebPartZoneID="Footer
" Url="Document Library 3" />
<View List="101" BaseViewID="0" WebPartZoneID="Footer
" Url="Document Library 4" />
<View List="101" BaseViewID="0" WebPartZoneID="Footer
" Url="Document Library 5" />
</
File>
</Module
>
</Modules>

After all, each Document Library did get created and had a unique Url. Nope. This just created 5 copies of Document Library 1 on the page.

Update: Thanks to Frans for the suggestion to change the Type in the ListTemplates section. It seems to be the only way to create multiple unique document libraries. At least you don't have to create a whole different folder under the LISTS directory and you can reuse the DOCLIB one. So basically in your ListTemplates section of ONET.XML do this:

<ListTemplate Name="doclib" DisplayName="Document Library 1" Type="500" BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" Image="/_layouts/images/itdl.gif" DocumentTemplate="101"/>
<ListTemplate Name="doclib" DisplayName="Document Library 2" Type="501" BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" Image="/_layouts/images/itdl.gif" DocumentTemplate="101
"/>
<ListTemplate Name="doclib" DisplayName="Document Library 3" Type="502" BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" Image="/_layouts/images/itdl.gif" DocumentTemplate="101
"/>
<ListTemplate Name="doclib" DisplayName="Document Library 4" Type="503" BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" Image="/_layouts/images/itdl.gif" DocumentTemplate="101
"/>
<ListTemplate Name="doclib" DisplayName="Document Library 5" Type="504" BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" Image="/_layouts/images/itdl.gif" DocumentTemplate="101"/>

It's the Type that has to be unique, not the Name. This will allow you to put multiple document libraries onto a single page when a new site is created from your template.

5 Comments

  • in onet.xml there is a section &quot;&lt;ListTemplates&gt;&quot; where you can specify all lists you want to use.

    You can copy the element with attribute 'Name=&quot;doclib&quot;' giving it a different 'Type'

    Now in section &quot;&lt;Lists&gt;&quot; you write the new 'Type' to one list and then in section &quot;&lt;Modules&gt;&quot; you add one 'View' where &quot;List=Type&quot;



    franciscor@cyc.es

  • Fran,



    That's a way to do it but it means I have to create a different type for each doclib which really bites if I have to create 15 different definitions when they're all the same.

  • i'm sorry but i don't know any different step to avoid this behavior.

  • Shows how much I know. I always thought you could have different numbers.



    So you'd create Doc Lib1 as 101; Doc Lib2 as 102 etc.



    I'm sure (fairly!) I did that in STS when I had time to experiment

  • Greetings from Malaga (Spain). Antonio :-)

Comments have been disabled for this content.