Today for something regarding one of the new features of SharePoint 13. There is the new attribute “ReplaceContent=TRUE” for the <File> element in <Module>.
Until SharePoint 2010, whenever we reactivate the PageLayout feature (the feature that provisions the page layouts in a master page gallery), web parts that have been added to the page layout are duplicated on the new page and we do not have a very standard solution to resolve this problem except for writing a feature receiver and removing the duplicated web parts.
In SharePoint 2013 is the new attribute “ReplaceContent=TRUE” of the <File> element and if we use this when provisioning the page layout it overrides the existing web parts on the page layouts. So whenever we create a new page from the given page layouts, web parts are not duplicated.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="MyPageLayouts" Url="_catalogs/masterpage" RootWebOnly="TRUE"> <File Path="MyPageLayouts\MyPageLayout.aspx" Url="MyPageLayouts.Intranet/MyPageLayout.aspx" Type="GhostableInLibrary" ReplaceContent="TRUE"> <!—- All our web parts goes here --> </File> </Module>
Have a look at the preceding example, I have set the ReplaceContent=”TRUE”. Because of this whenever I change, add or delete a web part in this elements.xml file and I need to reactivate the feature, the web parts on the page layouts are not duplicated but they do get overridden.
Other Usage example
I’ll like to share one more scenario related to this, I have a sandbox solution that I am deploying on Office 365. I was uploading my package file (.wsp) to the Solution Gallery and activating it. In my package I have one feature that is deploying my CSS file in the master page gallery since I do not have file system access. I had a change in CSS file, I did the change, packaged the solution, deactivated the solution first, uploaded it to the solution gallery and activated it. But my CSS changes are not reflected. Then I remembered the “ReplaceContent” attribute and I used it in the module element while provisioning the CSS file and wonder happened? It worked like a charm.
Feel free if you have some thoughts on this or please share your experience. Thanks
Best Recommended SharePoint 2013 Hosting
ASPHostPortal.com
ASPHostPortal.com is Perfect, suitable hosting plan for a starter in SharePoint. ASPHostPortal the leading provider of Windows hosting and affordable SharePoint Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability