Forum Discussion

Alan Trafford's avatar
Alan Trafford
Brass Contributor
Dec 07, 2016

Get the default page layout for an Enterprise Wiki?

Hi

 

Is there a way to use CSOM (Powershell or C#) to get the default page layout for an Enterprise Wiki site collection?

 

Thanks.

4 Replies

  • SharePoint Folder object has WelcomePage property.

    E.g., for a web: `oWeb.RootFolder.WelcomePage`.

     

    Page layout is not the same. For publishing web a default layout can be:

    - Gotten by retrieving DefaultPageLayout property

    - Redefined by SetDefaultPageLayout method

    Also, you can get a list of available page layouts:

    - GetAvailablePageLayouts

     

    PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(oWeb);
    PageLayout pageLayout = pubWeb.DefaultPageLayout;
    Console.WriteLine("Title: " + pageLayout.Name + ", Url: " + pageLayout.ServerRelativeUrl);

    Hope this was helpful.

    • Alan Trafford's avatar
      Alan Trafford
      Brass Contributor

      Hi Andrew Koltyakov

       

      Thanks for your reply, it helped me!

       

      Here is my Powershell code using PnP:

       

      Clear-Host
      
      Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/wiki -Credentials (Get-Credential)
      
      $context = Get-PnPContext $allProperties = Get-PnPProperty -ClientObject $context.Web -Property AllProperties

      $defaultLayoutPage = $allProperties['__DefaultPageLayout'] $defaultLayoutPage Disconnect-PnPOnline

       

  • Anonymous's avatar
    Anonymous
    You could get the homepage of any sitecollection using PNP https://dev.office.com/patterns-and-practices
    • Alan Trafford's avatar
      Alan Trafford
      Brass Contributor

      Hi Deleted

       

      It's not the homepage, but the default layout page that would be used when creating new Enterprise Wiki pages.

       

      Thanks.

Resources