Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Added getting and setting footer title and logo #2715

Merged
merged 10 commits into from
Jun 8, 2020
Prev Previous commit
Next Next commit
Added ability to getting and setting the title and logo shown in the …
…footer of a Modern Communication site
KoenZomers committed Jun 8, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 8c7d496dc2c2b7b179eea3b63eec3fe94703775f
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `Disable-PnPSharingForNonOwnersOfSite` and `Get-PnPSharingForNonOwnersOfSite` cmdlets to control disabling the ability for only owners of the site to be allowed to share the site or its files and folders with others [PR #2641](https://github.com/pnp/PnP-PowerShell/pull/2641)
- Added `Get-PnPIsSiteAliasAvailable` which allows checking if a certain alias is still available to create a new site collection with [PR #2698](https://github.com/pnp/PnP-PowerShell/pull/2698)
- Added `Get-PnPFooter` and `Set-PnPFooter` to work with the footer shown on Modern Communication pages [PR #2634](https://github.com/pnp/PnP-PowerShell/pull/2634)
- Added ability to getting and setting the title and logo shown in the footer of a Modern Communication site

### Changed
- Fixed uploading a file using `Add-PnPFile` using `-ContentType` throwing an exception [PR #2619](https://github.com/pnp/PnP-PowerShell/pull/2619)
2 changes: 2 additions & 0 deletions Commands/Branding/GetFooter.cs
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@ protected override void ExecuteCmdlet()
footer.Properties.Add(new PSVariableProperty(new PSVariable("IsEnabled", SelectedWeb.FooterEnabled)));
footer.Properties.Add(new PSVariableProperty(new PSVariable("Layout", SelectedWeb.FooterLayout)));
footer.Properties.Add(new PSVariableProperty(new PSVariable("BackgroundTheme", SelectedWeb.FooterEmphasis)));
footer.Properties.Add(new PSVariableProperty(new PSVariable("Title", SelectedWeb.GetFooterTitle())));
footer.Properties.Add(new PSVariableProperty(new PSVariable("LogoUrl", SelectedWeb.GetFooterLogoUrl())));

WriteObject(footer);
}
33 changes: 33 additions & 0 deletions Commands/Branding/SetFooter.cs
Original file line number Diff line number Diff line change
@@ -18,6 +18,14 @@ namespace SharePointPnP.PowerShell.Commands.Branding
Code = @"PS:> Set-PnPFooter -Enabled:$true -Layout Extended -BackgroundTheme Neutral",
Remarks = "Enables the footer to be shown on the current web with the extended layout using a neutral background",
SortOrder = 2)]
[CmdletExample(
Code = @"PS:> Set-PnPFooter -Title ""Contoso Inc."" -LogoUrl ""/sites/communication/Shared Documents/logo.png""",
Remarks = "Sets the title and logo shown in the footer",
SortOrder = 3)]
[CmdletExample(
Code = @"PS:> Set-PnPFooter -LogoUrl """"",
Remarks = "Removes the current logo shown in the footer",
SortOrder = 4)]
public class SetFooter : PnPWebCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "Indicates if the footer should be shown on the current web ($true) or if it should be hidden ($false)")]
@@ -29,6 +37,12 @@ public class SetFooter : PnPWebCmdlet
[Parameter(Mandatory = false, HelpMessage = "Defines the background emphasis of the content in the footer")]
public FooterVariantThemeType BackgroundTheme;

[Parameter(Mandatory = false, HelpMessage = "Defines the title displayed in the footer")]
public string Title;

[Parameter(Mandatory = false, HelpMessage = "Defines the server relative URL to the logo to be displayed in the footer. Provide an empty string to remove the current logo.")]
public string LogoUrl;

protected override void ExecuteCmdlet()
{
bool isDirty = false;
@@ -51,6 +65,25 @@ protected override void ExecuteCmdlet()
isDirty = true;
}

if (ParameterSpecified(nameof(Title)))
{
SelectedWeb.SetFooterTitle(Title);
// No isDirty is needed here as the above request will directly perform the update
}

if (ParameterSpecified(nameof(LogoUrl)))
{
if (LogoUrl == string.Empty)
{
SelectedWeb.RemoveFooterLogoUrl();
}
else
{
SelectedWeb.SetFooterLogoUrl(LogoUrl);
}
// No isDirty is needed here as the above request will directly perform the update
}

if (isDirty)
{
SelectedWeb.Update();