views:

227

answers:

1

Hi all,

I have a web part dashboard.cs which render some HTML according to records in a list. No I have a site definition created. I want to integrate this web part in my site defination as a feature so when I Build my project with the help of install.bat i want to install this feature which will deploy this web part on respective site. Now when I go to site settings->site features This feature must have to be listed over there and once I install this feature my web part will be get populated when I swich my page in edit mode and click on add web part button.

Can anybody help me..?

Thanks in advance Sachin

A: 

In the onet.xml file for your site definition be sure to include your feature under the SiteFeatures/WebFeatures section like below:

<SiteFeatures>
    <Feature ID="01D547B0-4C63-42d1-A7F9-4D34ACC4E718" />            
</SiteFeatures>
<WebFeatures>
    <Feature ID="657793AB-D427-4141-879C-BCFB6852B619" />
</WebFeatures>

If your feature is a site collection feature, then it goes under SiteFeatures. If it is a site feature then it goes under WebFeatures. Now, to automatically add an instance of your webpart to your webpart page you will be editing the elements.xml (elements manifest file) for your webpart deployment feature and embedding markup for the webpart instance within a <![CDATA[ tag like so:

    <Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
        <Module Name="HCPracticePortalWebPartPages" List="101" Url="Portal Pages">
            <File Url="BlankPortalPage.aspx" Name="NewPage.aspx" Type="GhostableInLibrary">
                <AllUsersWebPart WebPartZoneID="Top" WebPartOrder="1"><![CDATA[ 
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image"&gt;
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
<FrameType>None</FrameType>
<Title>$Resources:wp_SiteImage;</Title>
<iwp:ImageLink>/_layouts/images/homepage.gif</iwp:ImageLink>
<iwp:AlternativeText>$Resources:core,sitelogo_wss;</iwp:AlternativeText>
</WebPart>]]>
                </AllUsersWebPart>
            </File>
        </Module>
    </Elements>

The above markup was graciously borrowed from Using Features to Deploy Web Part Pages in WSS. I hope this helps.

Repo Man