Adding a Custom Web Part to a Site Definition

28 11 2008

I had to do this today and having looked around on the internet finding lots of conflicting examples, I thought I’d post the code that I used on here.

Basically what you need to do, is open the ONET.xml for your Site Definition.

Inside the ONET.xml file you will find a section called <Modules>, inside here should be a default module of some kind: <Module Name=”Default” Url=”” Path=””>.

It is inside here that you need to add the web part, to add a custom web part use the code below:

<AllUsersWebPart WebPartZoneID=”Left” WebPartOrder=”1″><![CDATA[
    <WebPart xmlns=”″ >
    <Title>’Title of Your Web Part’</Title>
    <Description>’Description For Your Web Part’</Description>
    <Assembly>Full Assembly (DLL) Details</Assembly>

Ensure that you put the full Assembly details in the <Assembly> Tag and the Class Name inside the <TypeName> Tag.

Perform an IISRESET and your done!

Footnote: You will only see the Web Part on new sites that you create and not existing ones.




Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: