Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Feature Stapler to change landing page of publishing site

$
0
0

This is turning out to be way more difficult than it should be. Can anyone tell me what I'm missing here?

Trying to change the landing (welcome) page of the ootb pubishing site to a custom one that already exists on the site collection. 

Feature 1 - StapleLandingPage Site Scoped
Event Receiver:

  try
            {
                SPWeb currentWeb = (SPWeb)properties.Feature.Parent;
                PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(currentWeb);

                SPFile landingPage = currentWeb.GetFile("/_catalogs/masterpage/customLandingPage.aspx");
                pubWeb.DefaultPage = landingPage;
                pubWeb.Update();

                // currentWeb.Dispose();
            }
            catch (Exception e)
            {
                //log etc..
            }

Feature 2 - StaplerFeature - Site Scoped - Feature item inlcudes an empty element called AssociateFeature

Elements.xml - 

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureSiteTemplateAssociation Id="fbc5ccd8-3cd5-451d-a0c7-9119d9aedf43" TemplateName="CMSPUBLISHING#0"/>
</Elements>

ID is my staplelandingpage feature guid 

That's it, I've also tried GLOBAL as TemplateName and that doesn't work either. I create a new site and get the default landing page, not my custom layout.


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>