v2 and v3 Web Parts in Site Definitions (onet.xml)

I am creating a site definition that involves both v2 and v3 web parts. Going through standard tutorials on creating site definitions, I copied and used the sts folder – which had only v2 web parts.

A v2 web part in onet.xml has the following format:

<alluserswebpart webpartzoneid="Right" webpartorder="1"><![CDATA[     <webpart xmlns="http://schemas.microsoft.com/WebPart/v2">      <assembly>Microsoft.SharePoint, Version= 12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</assembly>      <typename>Microsoft.SharePoint.WebPartPages.MembersWebPart</typename>      <title>$Resources:wp_Members;</title>      <description>$Resources:wp_Members_Desc;</description>      <frametype>Standard</frametype>      <isvisible>true</isvisible>   </webpart>]]></alluserswebpart>

I needed to add a v3 (custom web part) to the site definition. Of course the format above will not work (and I learned this through some trial and error).

So a v3 webpart looks in onet.xml looks like the following:

<AllUsersWebPart WebPartZoneID="LeftNavBar" WebPartOrder="1"><![CDATA[    <webParts>      <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">         <metaData>            <type name="YourCompany.SharePoint2007.SideNav.SiteNav, YourCompany.SharePoint2007.SiteNav, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e2c0c4fc62593f5e" />         <importErrorMessage>Cannot import this Web Part.</importErrorMessage>         </metaData>         <data>            <properties>               <property name="Title" type="string">Site Navigation</property>            </properties>         </data>      </webPart>   </webParts>]]>                  </AllUsersWebPart>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s