From a1fa833d2ccdcd9af96c9c4f8c58c24ad15ff355 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 2 May 2019 19:36:28 +0200 Subject: [PATCH 1/2] Added support for templates --- CHANGELOG.md | 11 +++++++++++ Commands/ClientSidePages/AddClientSidePage.cs | 11 +++++++++-- Commands/ClientSidePages/SetClientSidePage.cs | 8 +++++++- Commands/Enums/ClientSidePagePromoteType.cs | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bb45dbc2..2a1684917 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). +## [3.10.1906.0 - June 2019 Release] + +### Added + +### Changed + +### Deprecated + +### Contributors + ## [3.9.1905.0 - May 2019 Release] ### Added +- Added Template as a possible PromoteAs value for a Add-PnPClientSidePage and Set-PnPClientSidePage - Added -HeaderLayout and -HeaderEmphasis parameters to Set-PnPWeb - Support to specify lcid for Export-PnPTaxonomy for a particular termset - Added support in the Navigation cmdlets to manage the site footer on modern sites. diff --git a/Commands/ClientSidePages/AddClientSidePage.cs b/Commands/ClientSidePages/AddClientSidePage.cs index 351a95794..22dc35d7b 100644 --- a/Commands/ClientSidePages/AddClientSidePage.cs +++ b/Commands/ClientSidePages/AddClientSidePage.cs @@ -68,9 +68,16 @@ protected override void ExecuteCmdlet() // Create a page that persists immediately clientSidePage = SelectedWeb.AddClientSidePage(name); clientSidePage.LayoutType = LayoutType; - clientSidePage.Save(name); + if (PromoteAs == ClientSidePagePromoteType.Template) + { + clientSidePage.SaveAsTemplate(name); + } + else + { + clientSidePage.Save(name); + } - if(MyInvocation.BoundParameters.ContainsKey("ContentType")) + if (MyInvocation.BoundParameters.ContainsKey("ContentType")) { ContentType ct = null; if (ContentType.ContentType == null) diff --git a/Commands/ClientSidePages/SetClientSidePage.cs b/Commands/ClientSidePages/SetClientSidePage.cs index 0fd782f19..fadce961a 100644 --- a/Commands/ClientSidePages/SetClientSidePage.cs +++ b/Commands/ClientSidePages/SetClientSidePage.cs @@ -128,7 +128,13 @@ protected override void ExecuteCmdlet() } } - clientSidePage.Save(name); + if (PromoteAs == ClientSidePagePromoteType.Template) + { + clientSidePage.SaveAsTemplate(name); + } else + { + clientSidePage.Save(name); + } // If a specific promote type is specified, promote the page as Home or Article or ... switch (PromoteAs) diff --git a/Commands/Enums/ClientSidePagePromoteType.cs b/Commands/Enums/ClientSidePagePromoteType.cs index ebee41c61..7985589b5 100644 --- a/Commands/Enums/ClientSidePagePromoteType.cs +++ b/Commands/Enums/ClientSidePagePromoteType.cs @@ -12,6 +12,7 @@ public enum ClientSidePagePromoteType None = 0, HomePage = 1, NewsArticle = 2, + Template = 3 } } #endif From 465f16f14dab1e737d14bf23d760e6036f9f3638 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 2 May 2019 19:41:21 +0200 Subject: [PATCH 2/2] updated documentation --- Commands/ClientSidePages/AddClientSidePage.cs | 4 ++++ Commands/ClientSidePages/GetClientSidePage.cs | 6 +++++- Commands/ClientSidePages/RemoveClientSidePage.cs | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Commands/ClientSidePages/AddClientSidePage.cs b/Commands/ClientSidePages/AddClientSidePage.cs index 22dc35d7b..1b65621ab 100644 --- a/Commands/ClientSidePages/AddClientSidePage.cs +++ b/Commands/ClientSidePages/AddClientSidePage.cs @@ -19,6 +19,10 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages Code = @"PS:> Add-PnPClientSidePage -Name ""NewPage"" -ContentType ""MyPageContentType""", Remarks = "Creates a new Client-Side page named 'NewPage' and sets the content type to the content type specified", SortOrder = 2)] + [CmdletExample( + Code = @"PS:> Add-PnPClientSidePage -Name ""NewPageTemplate"" -PromoteAs Template", + Remarks = "Creates a new Client-Side page named 'NewPage' and saves as a template to the site.", + SortOrder = 2)] public class AddClientSidePage : PnPWebCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Specifies the name of the page.")] diff --git a/Commands/ClientSidePages/GetClientSidePage.cs b/Commands/ClientSidePages/GetClientSidePage.cs index e1963ff2b..05400c337 100644 --- a/Commands/ClientSidePages/GetClientSidePage.cs +++ b/Commands/ClientSidePages/GetClientSidePage.cs @@ -12,11 +12,15 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages [CmdletExample( Code = @"PS:> Get-PnPClientSidePage -Identity ""MyPage.aspx""", Remarks = "Gets the Modern Page (Client-Side) named 'MyPage.aspx' in the current SharePoint site", - SortOrder = 2)] + SortOrder = 1)] [CmdletExample( Code = @"PS:> Get-PnPClientSidePage ""MyPage""", Remarks = "Gets the Modern Page (Client-Side) named 'MyPage.aspx' in the current SharePoint site", SortOrder = 2)] + [CmdletExample( + Code = @"PS:> Get-PnPClientSidePage ""Templates/MyPageTemplate""", + Remarks = "Gets the Modern Page (Client-Side) named 'MyPageTemplate.aspx' from the templates folder of the Page Library in the current SharePoint site", + SortOrder = 3)] public class GetClientSidePage : PnPWebCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The name of the page")] diff --git a/Commands/ClientSidePages/RemoveClientSidePage.cs b/Commands/ClientSidePages/RemoveClientSidePage.cs index 78f31a7b7..7eeb556de 100644 --- a/Commands/ClientSidePages/RemoveClientSidePage.cs +++ b/Commands/ClientSidePages/RemoveClientSidePage.cs @@ -14,10 +14,14 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages Code = @"PS:> Remove-PnPClientSidePage -Identity ""MyPage""", Remarks = "Removes the Client-Side page named 'MyPage.aspx'", SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Remove-PnPClientSidePage -Identity ""Templates/MyPageTemplate""", + Remarks = "Removes the specified Client-Side page which is located in the Templates folder of the Site Pages library.", + SortOrder = 2)] [CmdletExample( Code = @"PS:> Remove-PnPClientSidePage $page", Remarks = "Removes the specified Client-Side page which is contained in the $page variable.", - SortOrder = 2)] + SortOrder = 3)] public class RemoveClientSidePage : PnPWebCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The name of the page")]