ページ変換フレームワークを使用する場合、ページ変換の実行方法を制御する方法がたくさんあります。 これを制御するモデルは、wiki および Web パーツ ページのインスタンスの PageTransformationInformation
一部として正しい構成を指定するか、ページ PublishingPageTransformationInformation
を発行するためのインスタンスを指定することです。 作成された変換インスタンスは、ページ変換を起動するために使用します。 この記事では、使用可能なオプションの詳細について説明します。
重要
SharePoint PnP モダン化は、PnP フレームワークの一部であり、継続的に進化しています。リリース ノートで常に最新の変更内容を確認してください。 問題が発生した場合は、「PnP フレームワークに関する GitHub の問題リスト」で問題を提出してください。
Overwrite オプション
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
Overwrite = true
を構成すると、ページ変換フレームワークは必要に応じてターゲット ページを上書きします。 既定では新しいページ名のプレフィックスが Migrated_ となります。つまり、Migrated_YourPage.aspx が既に存在する場合 (通常は以前のページ変換処理によって生じたもの) には上書きされます。 このオプションの使用法を示すスニペットを以下に記します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
Overwrite = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
Overwrite = true,
};
SourcePage オプション
型 | 指定のない場合の既定値 |
---|---|
ListItem | null |
通常、次のサンプルに示すようにコンストラクターを使用して設定します。 これは、ページがリストに含まれるときに最新化されるページを示します
PageTransformationInformation pti = new PageTransformationInformation(page)
{
Overwrite = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
Overwrite = true,
};
SourceFile オプション (2019 年 6 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
File | null |
ページがリストの外部に存在する場合に最新化するページを定義するために使用されます。そのため、サイトのルート フォルダーに格納されます。 これらのページには、Web パーツ ページのみを使用できます。
var fileToModernize = cc.Web.GetFileByServerRelativeUrl("/sites/myspecialsite/default.aspx");
cc.Load(fileToModernize);
cc.ExecuteQueryRetry();
PageTransformationInformation pti = new PageTransformationInformation(null)
{
SourceFile = true,
};
TargetPagePrefix オプション
型 | 指定のない場合の既定値 |
---|---|
文字列 | Migrated_ |
新しいモダン ページの名前は {TargetPagePrefix}{OriginalPageName} となります (例: Migrated_MyPage.aspx)。 別のプレフィックスを使用する場合に、このオプションを使用します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
TargetPagePrefix = "New_",
};
注:
このオプションは、ページ変換の発行には使用できません。
TargetPageTakesSourcePageName オプション
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
既定の動作の場合、作成されたモダン ページの名前は Migrated_ というプレフィックスで始まり、元のページは既存名を保持します。 このオプションを指定すると、新しく作成されたページが元のページの名前に置き換わり、元のページの名前にはプレフィックス Previous_ が付きます。 元のページを指すすべてのリンクが新しいモダン ページを読み込むようになるため、このオプションは、モダン ページに移行することが確実な場合に設定します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
TargetPageTakesSourcePageName = true,
};
重要
元のページの名前を Previous_ プレフィックスで始まるページの名前に変更する処理中は、元のページのバージョン履歴が保持されません。
注:
このオプションは、ページ変換の発行には使用できません。
SourcePagePrefix オプション
型 | 指定のない場合の既定値 |
---|---|
文字列 | Previous_ |
TargetPageTakesSourcePageName = true
を設定すると、元のページは既定のプレフィックス Previous_ によって名前変更されます。 別のプレフィックスを使用する場合に、このオプションを使用します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
SourcePagePrefix = "Old_",
};
注:
このオプションは、ページ変換の発行には使用できません。
TargetPageName オプション
型 | 指定のない場合の既定値 |
---|---|
文字列 | 空 |
必要に応じて、ターゲット ページのページ名をオーバーライドできます。 既定では、ページ変換エンジンは 1 つを生成しますが、オーバーライドする必要がある場合があります (たとえば、default.aspx は SitePages ライブラリの default.aspx ビュー ページと衝突します)。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
TargetPageName = "mypage.aspx",
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
TargetPageName = "mypage.aspx",
};
TargetPageFolder オプション (2019 年 11 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
文字列 | 空 |
必要に応じて、ターゲット ページを作成するフォルダーを指定できます。 フォルダーが自動的に作成された場合 (たとえば、追加の Wiki ページ ライブラリから変換していた場合など)、このパラメーターで指定されたフォルダーは自動生成されたフォルダーと組み合わされることに注意してください (オプションも使用 TargetPageFolderOverridesDefaultFolder
しない限り)。 フォルダーの入れ子構造を作成する場合は、MyFolder
または MyFolder/SubFolder
のようなフォルダーを指定できます。 <root>
値として指定すると、ターゲット サイト ページ ライブラリのルートをターゲットにできます (2020 年 1 月のリリース時点)。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
TargetPageFolder = "MyFolder",
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
TargetPageFolder = "MyFolder",
};
TargetPageFolderOverridesDefaultFolder オプション (2019 年 12 月のリリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
自動的に作成されたフォルダーがあるかどうかに関係なく、プロパティで TargetPageFolder
指定されたフォルダーを使用するようにページ変換を強制できます。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
TargetPageFolderOverridesDefaultFolder = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
TargetPageFolderOverridesDefaultFolder = true,
};
ReplaceHomePageWithDefaultHomePage オプション
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
既定の動作は、サイトのホームページを、他の通常ページと同様にモダン ページに変換することです。 このオプションを true に設定すると、サイトのホームページは '既定の' すぐに使用できるモダン ホームページ、つまりモダン チーム サイトを新たに作成した場合に得られるような状態になります。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
ReplaceHomePageWithDefaultHomePage = true,
};
注:
このオプションは、ページ変換の発行には使用できません。
KeepPageSpecificPermissions オプション
型 | 指定のない場合の既定値 |
---|---|
ブール | true |
既定の動作では、ソース ページ上に存在する可能性があるすべてのアイテム レベルのアクセス許可をコピーします。この動作を避ける場合には、このオプションを false に設定します
PageTransformationInformation pti = new PageTransformationInformation(page)
{
KeepPageSpecificPermissions = false,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
KeepPageSpecificPermissions = false,
};
CopyPageMetadata オプション (2019 年 2 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
ページ メタデータを収集するための列を追加して Wiki ページ ライブラリを拡張し、作成したモダン ページにこのメタデータをコピーする場合は、このオプションを true に設定します
PageTransformationInformation pti = new PageTransformationInformation(page)
{
CopyPageMetadata = true,
};
注:
このオプションは、ページ変換の発行には使用できません。 発行ページ レイアウト マッピング モデルを使用して、メタデータをコピーする必要があるかどうか、およびその方法を定義します。
注:
2019 年 10 月のリリースの時点で、ページ メタデータのコピーは、クロス サイト変換を実行する場合にも機能するため、元のソース ページとは異なるサイト コレクションでモダン ページを作成する場合にも機能します。
RemoveEmptySectionsAndColumns オプション (2019 年 3 月のリリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | true |
既定の動作では、空のセクションと列をすべて削除します (たとえば、3 列のレイアウトから変換し、中央の列に Web パーツが 1 つだけ含まれるようにします)。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
RemoveEmptySectionsAndColumns = false,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
RemoveEmptySectionsAndColumns = false,
};
MappingProperties ディクショナリ (2019 年 3 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
辞書<文字列,文字列> | 空 |
既定のマッピング ファイルは、マッピング プロパティを設定することで構成できます
PageTransformationInformation pti = new PageTransformationInformation(page)
{
// If target page exists, then overwrite it
Overwrite = true,
};
pti.MappingProperties["SummaryLinksToQuickLinks"] = "false";
pageTransformator.Transform(pti);
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
// If target page exists, then overwrite it
Overwrite = true,
};
pti.MappingProperties["SummaryLinksToQuickLinks"] = "false";
pageTransformator.Transform(pti);
PublishCreatedPage オプション (2019 年 4 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | true |
既定の動作では、作成したモダン ページを発行します。これを回避する場合は、このオプションを使用します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
PublishCreatedPage = false,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
PublishCreatedPage = false,
};
KeepPageCreationModificationInformation オプション (2019 年 10 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
既定の動作では、ソース ページの作成者、エディター、作成データ、変更日は保持されません。 これを変更するには、このオプションを使用します。
注:
このオプションは、ソース ページがモダン ページの対象となる宛先と同じ SPO テナントにある場合に機能します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
KeepPageCreationModificationInformation = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
KeepPageCreationModificationInformation = true,
};
PostAsNews オプション (2019 年 10 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
作成したページをニュースとして投稿します。 これは、 を使用 PublishCreatedPage
してページの発行を禁止した場合でも、ページも発行されることを意味します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
PostAsNews = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
PostAsNews = true,
};
DisablePageComments オプション (2019 年 4 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
既定の動作では、ページ コメントを有効のままにします。無効なページ コメントを含むページを作成する場合は、このオプションを使用します
PageTransformationInformation pti = new PageTransformationInformation(page)
{
DisablePageComments = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
DisablePageComments = true,
};
SkipUrlRewrite オプション (2019 年 5 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
既定の動作では、URL 書き換えを有効のままにします。URL 書き換えを無効にしたページを作成する場合は、このオプションを使用します。 詳細については、「URL マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
SkipUrlRewrite = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
SkipUrlRewrite = true,
};
UrlMappingFile オプション (2019 年 7 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
文字列 | 空 |
必要に応じて、カスタム URL マッピングを含むファイルを指定できます。 詳細については、「URL マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
UrlMappingFile = @"c:\temp\urlmappingfile.csv",
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
UrlMappingFile = @"c:\temp\urlmappingfile.csv",
};
SkipDefaultUrlRewrite オプション (2019 年 9 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
既定の動作では、既定の URL 書き換えを実行します。 カスタム URL マッピング ファイルを使用していて、既定の URL 書き換えロジックを適用しない場合は、このプロパティを設定します。 詳細については、「URL マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
SkipDefaultUrlRewrite = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
SkipDefaultUrlRewrite = true,
};
AddTableListImageAsImageWebPart オプション (2019 年 10 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | true |
テーブル/リスト内にある画像も、そのテーブル/リストの下に個別の画像 Web パーツとして作成されます。 これらの個別の AddTableListImageAsImageWebPart
イメージ Web パーツの作成を停止する場合は、 プロパティを false に設定します。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
AddTableListImageAsImageWebPart = false,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
AddTableListImageAsImageWebPart = false,
};
UserMappingFile オプション (2019 年 11 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
文字列 | 空 |
必要に応じて、カスタム ユーザー マッピングを使用してファイルを指定できます。 詳細については、「ユーザー マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
UserMappingFile = @"c:\temp\usermappingfile.csv",
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
UserMappingFile = @"c:\temp\usermappingfile.csv",
};
LDAPConnectionString オプション (2019 年 11 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
文字列 | 空 |
必要に応じて、Active Directory 環境にカスタム LDAP 接続文字列を指定できます。 詳細については、「ユーザー マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
LDAPConnectionString = "LDAP://OU=Test,DC=CONTOSO,DC=COM",
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
LDAPConnectionString = "LDAP://OU=Test,DC=CONTOSO,DC=COM",
};
SkipUserMapping オプション (2019 年 11 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
既定の動作では、オンプレミスの SharePoint から送信されるページを変換するときに、常にユーザー マッピングを実行します。このオプションを使用して無効にします。 詳細については、「URL マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
SkipUserMapping = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
SkipUserMapping = true,
};
TermMappingFile オプション (2020 年 3 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
文字列 | 空 |
必要に応じて、カスタム用語マッピングを使用してファイルを指定できます。 詳細については、「用語マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
TermMappingFile = @"c:\temp\termmappingfile.csv",
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
TermMappingFile = @"c:\temp\termmappingfile.csv",
};
SkipTermStoreMapping オプション (2020 年 3 月リリース時点)
型 | 指定のない場合の既定値 |
---|---|
ブール | false |
標準的な動作は、既定の用語マッピングを実行することです。 用語マッピングを行いたくない場合は、このプロパティを設定します。 詳細については、「用語マッピング」の記事を参照してください。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
SkipTermStoreMapping = true,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
SkipTermStoreMapping = true,
};
HandleWikiImagesAndVideos オプション
型 | 指定のない場合の既定値 |
---|---|
ブール | true |
wiki ページに、モダン テキスト パーツでは不可能な埋め込みのビデオとテキストを含めることができます。 既定では、wiki テキストは埋め込みの画像またはビデオごとに分割されます。ビデオまたは画像 Web パーツがモダン ページに追加されてから、残りの元のテキストが追加されます。 この自動修正を望まない場合には、このオプションを false に設定できます。その場合、それぞれの埋め込みの画像とビデオは、個々のビデオと画像の Web パーツがページ下部で結合したテキスト プレースホルダーに置き換えられます。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
HandleWikiImagesAndVideos = false,
};
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
HandleWikiImagesAndVideos = false,
};
PageHeader オプション
型 | 指定のない場合の既定値 |
---|---|
ClientSidePageHeader | Null |
モダン ページの既定のページ ヘッダーの型は ClientSidePageHeaderType.None
で、wiki ページ ヘッダーと最も近くなります。 ただし (グレー領域の大きな) 既定のモダン ページ ヘッダーにする場合には、このオプションを使用してそのようにできます (下のサンプルを参照)。 または、背景画像、配置などの関連オプションすべてを使ってカスタム ページ ヘッダーを構成することもできます。
PageTransformationInformation pti = new PageTransformationInformation(page)
{
PageHeader = new ClientSidePageHeader(cc, ClientSidePageHeaderType.Default, null),
};
注:
このオプションは、ページ変換の発行には使用できません。 ページ レイアウト マッピング モデルを使用して、ページ ヘッダーの作成方法を決定します。
PageTitleOverride オプション
型 | 指定のない場合の既定値 |
---|---|
Func<文字列、string> | null |
モダン ページのタイトルは、ソース ページから名前を取り出すか、拡張子を取り除いて付けられます。ただし、このコールアウトによって変換フローに任意のカスタム ページ タイトルを挿入できます。 示されている例の場合、既定のタイトルにサフィックス _1 が追加されます。
// Local functions
string titleOverride(string title)
{
return $"{title}_1";
}
PageTransformationInformation pti = new PageTransformationInformation(page)
{
PageTitleOverride = titleOverride,
};
// Local functions
string titleOverride(string title)
{
return $"{title}_1";
}
PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation(page)
{
PageTitleOverride = titleOverride,
};
LayoutTransformatorOverride オプション
型 | 指定のない場合の既定値 |
---|---|
Func<ClientSidePage、ILayoutTransformator> | null |
ページ変換エンジンの既定のレイアウト変換機能では、すぐに使用できる wiki と Web パーツのあらゆるページ レイアウトを処理できますが、これを上書きする場合には独自のものを指定することもできます。
public class MyLayout : ILayoutTransformator
{
private ClientSidePage page;
public MyLayout(ClientSidePage page)
{
this.page = page;
}
public void Transform(PageLayout layout)
{
// custom layout transformation...add sections to the target page based upon the recieved page layout
switch (layout)
{
case PageLayout.Wiki_OneColumn:
case PageLayout.WebPart_FullPageVertical:
case PageLayout.Wiki_Custom:
case PageLayout.WebPart_Custom:
{
page.AddSection(CanvasSectionTemplate.OneColumn, 1);
return;
}
// add more incoming layouts...
default:
{
page.AddSection(CanvasSectionTemplate.OneColumn, 1);
return;
}
}
}
}
// Local functions
ILayoutTransformator layoutOverride(ClientSidePage cp)
{
return new MyLayout();
}
PageTransformationInformation pti = new PageTransformationInformation(page)
{
LayoutTransformatorOverride = layoutOverride,
};