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

Im trying to create a site definition using onet.xml in sharepoint 2010. So far things are going well however I am now having a problem getting the subsite to inherit the global navigation from its parent when its created.

my parent nav bar which I want to inherit from

parent nav bar

my nav bar when I create my sub site through my site definition

child site nav bar

my onet.xml so far

<?xml version="1.0" encoding="utf-8"?>
<Project Title="News Portal" Revision="1" ListDir="$Resources:core,lists_Folder;" xmlns:ows="Microsoft SharePoint" UIVersion="4">
  <NavBars>
   <!-- Added this in as per answer //-->
   <NavBar Name="SharePoint Top Navbar" ID="1002"></NavBar>
 </NavBars>
 <ListTemplates>
<ListTemplate Name="NewsItems" DisplayName="$Resources:GCSites,GC_NewsPortalTitle;" Type="666" BaseType="0" OnQuickLaunch="TRUE" FolderCreation="TRUE" AllowDeletion="FALSE" Unique="TRUE" DisallowContentTypes="FALSE" SecurityBits="11" Description="News Items" Image="/_layouts/images/itcat.gif">
</ListTemplate>
</ListTemplates>
<DocumentTemplates>
</DocumentTemplates>
<Configurations>
<Configuration ID="0" Name="NewsPortal" MasterUrl="_catalogs/masterpage/inSightMaster2.master">
    <Lists>
        <List Type="666"
Title="News Items"
Url="$Resources:core,lists_Folder;/$Resources:GCSites,GC_NewsPortalTitle;"
Name="News Portal List"
QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:GCSites,GC_NewsPortalTitle;/allitems.aspx" />
    </Lists>
    <SiteFeatures>
    </SiteFeatures>
  <WebFeatures>
  </WebFeatures>
  <Modules>
    <Module Name="BasicHome" />
    <!--<Module Name="NewsPage" />//-->
  </Modules>
    <WebFeatures>
    <!--THESE FEATURES DONT SEEM TO GET PICKED UP //-->
        <Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
            <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
                <Property Key="InheritGlobalNavigation" Value="true"/>
                <Property Key="ShowSiblings" Value="true"/>
                <Property Key="IncludeSubSites" Value="true"/>
            </Properties>
        </Feature>
    </WebFeatures>
</Configuration>
</Configurations>
<Modules>
    <!-- Need to implement Modules for page views. For more info please view http://msdn.microsoft.com/en-us/library/ms474369.aspx -->
    <!--<module Name="NewsPage"  Url="$Resources:core,lists_Folder;/$Resources:GCSites,GC_NewsItemsFolder;" Path="Lists\NewsItems">
        <File Url="allitems.aspx" IgnoreIfAlreadyExists="TRUE">
            <View List="207" BaseViewID="8" WebPartZoneId="Left" WebPartOrder="1">
                <![CDATA[]]>
            </View>
        </File>
    </module>//-->
    <Module Name="BasicHome" Url="" Path="">
        <File Url="default.aspx" IgnoreIfAlreadyExists="TRUE">
        </File>
    </Module>
</Modules>
<ServerEmailFooter>$Resources:ServerEmailFooter;</ServerEmailFooter>

my webtemp.newsportal.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="14.0.4762" _dal="1" -->
<!-- _LocalBinding -->
<Templates xmlns:ows="Microsoft SharePoint">
 <Template Name="NewsPortal" ID="60010">
 <Configuration ID="0"
                Title="News Portal"
                Description="News Portal"
                RootWebOnly="FALSE"
                Hidden="FALSE"
                DisplayCategory="GC Portals" />    
 </Template>
</Templates>

My current active features:-

Advanced Web Analytics Disposition Approval Workflow Publishing Approval Workflow SharePoint Server Publishing Infrastructure Workflows

Can you see any reason why these navigation settings don't get picked up when I create a site using my new site definition.

Thanks in advance!

Nicholas

share|improve this question

3 Answers 3

Use the NavBars Element in the onet.xml file ...

<NavBars> <NavBar Name="SharePoint Top Navbar" ID="1002"></NavBar> </NavBars>

That will display your global navigation within the Site Definition ...

In a non publishing site, you should be able to use web.Navigation.UseShared = true; ... where web is SPWeb type.

In a publishing site, you should be able to use pw.Navigation.InheritGlobal = true; ... where pw is PublishingWeb. Although by default with the NavBar element, you should see global navigation inheriting.

You should also note, if you want to activate all publishing features (including Pages list) that you will need to add the below feature definitions to your onet.xml WebFeatures ... then staple any custom features in there after ...

 <!-- Include the common WSSListTemplateFeatures used by CMS -->
    <Feature ID="00BFEA71-DE22-43B2-A848-C05709900100"></Feature>
    <Feature ID="00BFEA71-E717-4E80-AA17-D0C71B360101"></Feature>
    <Feature ID="00BFEA71-52D4-45B3-B544-B1C71B620109"></Feature>
    <Feature ID="00BFEA71-A83E-497E-9BA0-7A5C597D0107"></Feature>
    <Feature ID="00BFEA71-4EA5-48D4-A4AD-305CF7030140"></Feature>
    <Feature ID="00BFEA71-F600-43F6-A895-40C0DE7B0117"></Feature>
    <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"></Feature>
    <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="ChromeMasterUrl" Value=""/>
        <Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/default.aspx"/>
        <Property Key="PagesListUrl" Value=""/>
        <Property Key="AvailableWebTemplates" Value=""/>
        <Property Key="AvailablePageLayouts" Value=""/>
        <Property Key="SimplePublishing" Value="true" />
      </Properties>
    </Feature>
    <Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="InheritGlobalNavigation" Value="true"/>
        <Property Key="ShowSiblings" Value="true"/>
        <Property Key="IncludeSubSites" Value="true"/>
      </Properties>
    </Feature>
    <Feature ID="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB">
      <!-- Office SharePoint Server Publishing -->
    </Feature>
share|improve this answer
    
This did not work. I still have the navigation which is not inheriting from the parent navbar :-( but thanks for your answer :-) –  Nicholas King Jul 26 '12 at 8:33
    
Alright - then in a feature ... add this code: web.Navigation.UseShared = true; ... where web is SPWeb ... get er done ... –  thastark Jul 26 '12 at 14:25
    
Thanks for the help thestark, i have fixed the issue but i cant mark my answer correct till tomorrow, the issue was i had 2 webfeature elements in my onet.xml –  Nicholas King Jul 26 '12 at 14:28

The navigation inheritance is a functionality of Publishing feature. This feature changes data provider for navigation by delegate control. Are you sure that your site definition activates this feature?

share|improve this answer
    
I'm not certain that the feature is being activated by the site definition. I do know that no errors are being thrown when I create the site definition. Is there a way of debugging the site definition as its being created? Thanks –  Nicholas King Jul 26 '12 at 8:33
    
Although the publishing feature is active as far as I can see. The parent site is a publishing portal –  Nicholas King Jul 26 '12 at 10:20
up vote 0 down vote accepted

Found the problem in the onet.xml, I have 2 webfeature elements, the first one being empty. So i guess it was only running the first webfeature element as per the schema set out by ms http://msdn.microsoft.com/en-us/library/ms467789.aspx only one webfeature element can exist.

<Configuration ID="0" Name="NewsPortal" MasterUrl="_catalogs/masterpage/inSightMaster2.master">
<Lists>
    <List Type="666"
Title="News Items"
Url="$Resources:core,lists_Folder;/$Resources:GCSites,GC_NewsPortalTitle;"
Name="News Portal List"
QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:GCSites,GC_NewsPortalTitle;/allitems.aspx" />
</Lists>
<SiteFeatures>
</SiteFeatures>
<WebFeatures>
</WebFeatures>
<Modules>
<Module Name="BasicHome" />
<!--<Module Name="NewsPage" />//-->
</Modules>
<WebFeatures>
<!--THESE FEATURES DONT SEEM TO GET PICKED UP //-->
    <Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
        <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
            <Property Key="InheritGlobalNavigation" Value="true"/>
            <Property Key="ShowSiblings" Value="true"/>
            <Property Key="IncludeSubSites" Value="true"/>
        </Properties>
    </Feature>
</WebFeatures>

Thanks for all your answers and suggestions and views.

Nicholas

share|improve this answer

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.