6

Experience Manager (XPM) (SDL Tridion 2011 SP1 のユーザー インターフェイス アップデート) を使用すると、管理者はページ タイプを作成できます。このページ タイプには、ページと同じようにコンポーネント プレゼンテーションが含まれますが、追加のコンテンツ タイプを作成および許可する方法に関するルールも追加できます。

特定のページ タイプについて、コンテンツ タイプの選択を制限することで、作成者のオプションを簡素化したいと考えています。

私たちができることを理解しています:

  • コンテンツ タイプを制限して、特定のページ タイプに対して作成者が特定の定義済みコンテンツ タイプのみを作成できるようにします。
  • ダッシュボードで、選択を解除して、上記を事前定義されたコンテンツ タイプのみに完全に制限します。Content Types Already Used on the Page
  • 数量制限とともにスキーマとテンプレートの組み合わせを指定するリージョンを使用します。作成者は、特定のタイプと数量のコンポーネントのみをこれらの領域に追加 (ドラッグ アンド ドロップ) できます。たとえば、次のように出力しStagingてリージョンを作成できます。
<div>
<!-- Start Region: {
  title: "Promos",
  allowedComponentTypes: [
    {
      schema: "tcm:2-42-8",
      template: "tcm:2-43-32"
    },
  ],
  minOccurs: 1,
  maxOccurs: 3
} -->
<!-- place the matching CPs here with template logic (e.g. TemplateBeginRepeat/ TemplateBeginIf with DWT) -->
</div>
  • 作成者には、挿入したいコンポーネントが表示される場合があります (下の画像)。
  • ただし、フォルダーのアクセス許可により、作成者がコンテンツの挿入ライブラリで表示/使用できるコンポーネントが制限される可能性があります

コンテンツを挿入

私はそれらすべてを手に入れましたか?特定のページ タイプで許可されるコンテンツを制限する方法について、XPM 機能または考えられる拡張機能の他の方法はありますか?

4

1 に答える 1

4

アルビン、あなたはあなたの質問のほとんどのオプションを提供しました。カスタムエラーメッセージが必要な場合、またはさらに細かいレベルの制御が必要な場合の別のオプションは、イベントシステムを使用することです。ページの保存イベント開始フェーズをサブスクライブし、不要なコンポーネントの表示がページにある場合に例外をスローする検証コードを記述します。

ページタイプは実際にはページテンプレート、ページ上のメタデータ、およびページ上のコンポーネントプレゼンテーションのタイプの組み合わせであるため、必要なページタイプを処理していることを確認し、そうでないCPが発生した場合は確認する必要があります。私たちが望むものと一致すれば、単に例外をスローすることができます。ここにいくつかの簡単なコードがあります:

[TcmExtension("Page Save Events")]
public class PageSaveEvents : TcmExtension
{
    public PageSaveEvents()
    {
        EventSystem.Subscribe<Page, SaveEventArgs>(ValidateAllowedContentTypes, EventPhases.Initiated);
    }

    public void ValidateAllowedContentTypes(Page p, SaveEventArgs args, EventPhases phases)
    {
        if (p.PageTemplate.Title != "My allowed page template" && p.MetadataSchema.Title != "My allowed page metadata schema")
        {
            if (!ValidateAllowedContentTypes(p))
            {
                throw new Exception("Content Type not allowed on a page of this type.");
            } 
        }
    }

    private bool ValidateAllowedContentTypes(Page p)
    {
        string ALLOWED_SCHEMAS = "My Allowed Schema A; My Allowed Schema B; My Allowed Schema C; etc";  //to-do put these in a parameter schema on the page template
        string ALLOWED_COMPONENT_TEMPLATES = "My Allowed Template 1; My Allowed Template 2; My Allowed Template 3; etc"; //to-do put these in a parameter schema on the page template

        bool ok = true;
        foreach (ComponentPresentation cp in p.ComponentPresentations)
        {
            if (!(ALLOWED_SCHEMAS.Contains(cp.Component.Schema.Title) && ALLOWED_COMPONENT_TEMPLATES.Contains(cp.ComponentTemplate.Title)))
            {
                ok = false;
                break;
            }
        }

        return ok;
    }
}
于 2013-01-24T05:30:52.860 に答える