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 have a custom HTML menu in my MasterPage. I would like to have it in a separate file so it can be easier to update. Is it possible to do an Include?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can add a static Content Editor Web Part to your master page and then set it to load that content from an external file.

Here's some steps based off of a quick experiment I just did - I used SharePoint designer for this.

  1. Add a ContentPlaceHolder to your master page where you want this content to go.
  2. Insert a Content Editor Web Part into this content placeholder.
  3. Set the CEWP's ChromeType to None and set it to load its content from /Documents/menu.html (or wherever your HTML is located).

Content editor web part configuration

After that, you should be set. Here's the code that these steps generated in my master page:

<asp:ContentPlaceHolder ID="PlaceHolderCopyright" runat="server">
<WebPartPages:ContentEditorWebPart webpart="true" runat="server" __webpartid="{3762918C-2C41-41CD-8531-C8834D56C256}">
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Content Editor</Title>
  <FrameType>None</FrameType>
  <Description>Allows authors to enter rich text content.</Description>
  <IsIncluded>true</IsIncluded>
  <PartOrder>0</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <AllowConnect>true</AllowConnect>
  <AllowEdit>true</AllowEdit>
  <AllowHide>true</AllowHide>
  <IsVisible>true</IsVisible>
  <DetailLink />
  <HelpLink />
  <HelpMode>Modeless</HelpMode>
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
  <IsIncludedFilter />
  <ExportControlledProperties>true</ExportControlledProperties>
  <ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID>
  <ID>g_3762918c_2c41_41cd_8531_c8834d56c256</ID>
  <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">/SiteAssets/test.html</ContentLink>
  <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
  <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart></WebPartPages:ContentEditorWebPart>

</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="PlaceHolderCopyright" runat="server">

<p></p>
<WebPartPages:ContentEditorWebPart webpart="true" runat="server" __webpartid="{3762918C-2C41-41CD-8531-C8834D56C256}">
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Content Editor</Title>
  <FrameType>None</FrameType>
  <Description>Allows authors to enter rich text content.</Description>
  <IsIncluded>true</IsIncluded>
  <PartOrder>0</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <AllowConnect>true</AllowConnect>
  <AllowEdit>true</AllowEdit>
  <AllowHide>true</AllowHide>
  <IsVisible>true</IsVisible>
  <DetailLink />
  <HelpLink />
  <HelpMode>Modeless</HelpMode>
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
  <IsIncludedFilter />
  <ExportControlledProperties>true</ExportControlledProperties>
  <ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID>
  <ID>g_3762918c_2c41_41cd_8531_c8834d56c256</ID>
  <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">/SiteAssets/test.html</ContentLink>
  <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
  <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart></WebPartPages:ContentEditorWebPart>

</asp:ContentPlaceHolder>

Hope this helps! You could also use JavaScript to dynamically load in content if the above approach isn't what you're looking for.

share|improve this answer
    
That worked great! Thanks! –  Rick Nov 2 '12 at 15:49
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.