博客地址:http://blog.csdn.net/FoxDave
SharePoint现代化用户接口处理品牌风格的方式跟经典SharePoint不同;特别地,它忽略了自定义母版页或外部CSS配置,这些在现代化网站并不可用。我们可以选择继续保留这些内容,它们仍然能够对经典的用户接口页面起作用,但是切换回默认母版页并移除外部样式显然是更干净整洁的方式。
除了自定义母版页和外部样式设置之外,我们可能还使用了经典的自定义主题。这些经典的自定义主题在现代化用户接口下仍然能工作,但是面向未来更好的方式是新的租户控制的SharePoint主题,同样也能在新旧两种模式下工作。
检测使用了自定义母版页和外部样式的网站
进行检测推荐使用之前介绍的扫描工具:SharePoint "Modern" user interface experience scanner。它会在我们的租户范围内对所有网站进行深度的分析,创建相应的报告告知我们关于不兼容母版页和外部样式的具体细节,我们可以基于报告去修复这些网站。
复原到默认设置
下面是PnP(Patterns and Practices)的PowerShell脚本用来复原到默认设置:
$minimumVersion = New-Object System.Version("2.24.1803.0")
if (-not (Get-InstalledModule -Name SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -ErrorAction Ignore))
{
Install-Module SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -Scope CurrentUser
}
Import-Module SharePointPnPPowerShellOnline -DisableNameChecking -MinimumVersion $minimumVersion
Connect-PnPOnline -Url "<your site url>"
# Set out-of-the-box master page
Set-PnPMasterPage -MasterPageSiteRelativeUrl _catalogs/masterpage/seattle.master -CustomMasterPageSiteRelativeUrl _catalogs/masterpage/seattle.master
# Remove the alternate CSS setting
$web = Get-PnPWeb -Includes AlternateCssUrl
$web.AlternateCssUrl = ""
$web.Context.ExecuteQuery()
使用租户控制的SharePoint主题
SharePoint提供了一些列拆箱即用的默认主题供我们使用,但是如果我们想要推广我们的公司品牌,我们应该创建自己的公司主题并隐藏默认的主题。配置完成后,用户只能从我们配置的主题中进行选择,我们可以通过编程的方式将这种主题设置作为网站现代化的一部分。
添加一个SharePoint公司主题
下面是PnP的PowerShell脚本用来演示如何添加一个SharePoint公司主题:
$minimumVersion = New-Object System.Version("2.24.1803.0")
if (-not (Get-InstalledModule -Name SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -ErrorAction Ignore))
{
Install-Module SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -Scope CurrentUser
}
Import-Module SharePointPnPPowerShellOnline -DisableNameChecking -MinimumVersion $minimumVersion
Connect-PnPOnline -Url "<your tenant admin url>"
# Define your company theme colors
$themepalette = @{
"themePrimary" = "#00ffff";
"themeLighterAlt" = "#f3fcfc";
"themeLighter" = "#daffff";
"themeLight" = "#affefe";
"themeTertiary" = "#76ffff";
"themeSecondary" = "#39ffff";
"themeDarkAlt" = "#00c4c4";
"themeDark" = "#009090";
"themeDarker" = "#005252";
"neutralLighterAlt" = "#f8f8f8";
"neutralLighter" = "#f4f4f4";
"neutralLight" = "#eaeaea";
"neutralQuaternaryAlt" = "#dadada";
"neutralQuaternary" = "#d0d0d0";
"neutralTertiaryAlt" = "#c8c8c8";
"neutralTertiary" = "#a6a6a6";
"neutralSecondaryAlt" = "#767676";
"neutralSecondary" = "#666666";
"neutralPrimary" = "#333";
"neutralPrimaryAlt" = "#3c3c3c";
"neutralDark" = "#212121";
"black" = "#000000";
"white" = "#fff";
"primaryBackground" = "#fff";
"primaryText" = "#333"
}
# Add the company theme
Add-PnPTenantTheme -Identity "CustomCompanyTheme" -Palette $themepalette -IsInverted:$false
使用我们的SharePoint公司主题
我们可以通过下面的脚本来设置使用我们的公司主题:
$minimumVersion = New-Object System.Version("2.24.1803.0")
if (-not (Get-InstalledModule -Name SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -ErrorAction Ignore))
{
Install-Module SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -Scope CurrentUser
}
Import-Module SharePointPnPPowerShellOnline -DisableNameChecking -MinimumVersion $minimumVersion
Connect-PnPOnline -Url "<your site url>"
# Set the company theme
Set-PnPWebTheme -Theme "CustomCompanyTheme"