Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to make 3 lists in root site & 2 subsites under the root site.

As soon as I create subsites from portal.xml my 3 lists are not showing.

share|improve this question
    
Do you have features which create your lists? What the scope of these fetures is? –  Andrew Adamich Mar 12 '13 at 13:22
    
I have features on Site level. –  Harsh Bhavsar Mar 13 '13 at 3:52
add comment

3 Answers 3

Go to site settings and choose "add an app". Then select a list type.

For creating sub site , you have to choose "add a page" in site settings.

share|improve this answer
    
I am creating it in Visual Studio.Not Manually. –  Harsh Bhavsar Mar 12 '13 at 12:18
add comment

I suppose you have a site template in your site definition onet.xml,

To be able to create lists in the site definition you should activate your features creating lists in your site template definition w

To activate feature on the root site in the template you apply to your root site in the section "SiteFeatures" you should call feature activating. This should be similar to this:

<Configuration ID="99" Name="TemplateName" Title="Site title">
     <Lists />
     <SiteFeatures>
       <!-- Your feature creating lists on root web-->
       <Feature ID="C85E5759-F323-4EFB-B548-443D2216EFB5" />
     </SiteFeatures>
     <WebFeatures>
        ...
     </WebFeatures>
     <Modules>
       <Module Name="Root" />
     </Modules>
</Configuration>

Note that it is best to create separate template for your sub site with different ID and activate features for web level in this template which will be applied to sub site.

Hope it helps,

If you have more question...

Andrew

share|improve this answer
    
I am doing the same thing but I am not able to make subsite & list simultaneously in one sitedefinition. –  Harsh Bhavsar Mar 14 '13 at 4:33
    
You site definition contains (as it says) definitions of the site (templates). You should create create minimum two templates - one for root web and the other for your subsites. When create your root site - apply root site template. When craete subsite - apply subsite template. As your lists should be created on root site - activate list feature in the "SiteFeatures" section while on the subsite template you do not have to do this. –  Andrew Adamich Mar 14 '13 at 7:48
    
I want to make lists & subsite on the root site. –  Harsh Bhavsar Mar 14 '13 at 8:42
    
How do you create your subsites? Inside the sitedefinition? External script? –  Andrew Adamich Mar 14 '13 at 9:19
    
<portal xmlns="PortalTemplate.xsd">in subsite.xml & ref that file in provision data in webtemp file. –  Harsh Bhavsar Mar 14 '13 at 9:23
show 3 more comments
up vote 0 down vote accepted

Done by adding feature & write following code in feature.EventReceiver file

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    SPSite site = properties.Feature.Parent as SPSite;
    site.RootWeb.Webs.Add("Subsite", "Sub site", "Description", 1033, "Template#0",true, false); 
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.