Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tridion 如何在Experience Manager中限制给定页面类型的内容类型_Tridion_Tridion 2011 - Fatal编程技术网

Tridion 如何在Experience Manager中限制给定页面类型的内容类型

Tridion 如何在Experience Manager中限制给定页面类型的内容类型,tridion,tridion-2011,Tridion,Tridion 2011,Experience Manager(XPM)(SDL Tridion 2011 SP1的用户界面更新)允许管理员创建页面类型,这些页面类型具有与页面一样的组件演示,但也添加了有关如何创建和允许其他内容类型的规则 对于给定的页面类型,我希望通过限制内容类型的选择来简化作者的选项 我知道我们可以: 限制内容类型,以便对于给定的页面类型,作者只能创建特定的 在仪表板中,通过取消选择页面上已使用的内容类型,将上述内容完全限制为预定义的内容类型 使用指定模式和模板组合以及数量限制的。作者只能向这些区域

Experience Manager(XPM)(SDL Tridion 2011 SP1的用户界面更新)允许管理员创建页面类型,这些页面类型具有与页面一样的组件演示,但也添加了有关如何创建和允许其他内容类型的规则

对于给定的页面类型,我希望通过限制内容类型的选择来简化作者的选项

我知道我们可以:

  • 限制内容类型,以便对于给定的页面类型,作者只能创建特定的
  • 在仪表板中,通过取消选择页面上已使用的
    内容类型,将上述内容完全限制为预定义的内容类型
  • 使用指定模式和模板组合以及数量限制的。作者只能向这些区域添加(拖放)特定类型和数量的组件。例如,我们可以在
    Staging
    上输出以下内容以创建区域:

  • 作者可能仍会看到他们可能要插入的组件(下图),但如果区域控制允许的内容,则无法添加这些组件
  • 但是,文件夹权限可以减少作者在“插入内容库”中可以看到/使用的组件


我都拿到了吗?XPM功能中的任何其他方法,或者考虑如何限制给定Page Type的允许内容的可能扩展?

< P>阿尔文,您几乎提供了问题中的大部分选项。如果需要自定义错误消息或更精细的控制级别,则另一个选项是使用事件系统。订阅页面的save event Initiated(保存事件启动)阶段,并编写一些验证代码,以便在页面上出现不需要的组件表示时引发异常

由于页面类型实际上是页面模板、页面上的任何元数据和页面上组件表示的类型的组合,因此我们需要检查是否正在处理所需的页面类型,如果遇到与我们所需不匹配的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;
    }
}
[TcmExtension(“页面保存事件”)]
公共类PageSaveEvents:TcmExtension
{
公共页面保存事件()
{
订阅(ValidateAllowedContentTypes,EventPhases.Initiated);
}
public void ValidateAllowedContentTypes(第p页,SaveEventArgs参数,EventPhases)
{
if(p.PageTemplate.Title!=“我允许的页面模板”&&p.MetadataSchema.Title!=“我允许的页面元数据架构”)
{
如果(!ValidateAllowedContentTypes(p))
{
抛出新异常(“此类型的页面上不允许使用内容类型”);
} 
}
}
私有bool ValidateAllowedContentTypes(第p页)
{
string ALLOWED_SCHEMAS=“我允许的模式A;我允许的模式B;我允许的模式C;etc”//to-do将它们放在页面模板的参数模式中
string ALLOWED\u COMPONENT\u TEMPLATES=“My ALLOWED Template 1;My ALLOWED Template 2;My ALLOWED Template 3;etc”///to-do将它们放在页面模板的参数架构中
bool ok=true;
foreach(p.ComponentPresentations中的ComponentPresentation cp)
{
if(!(ALLOWED_SCHEMAS.Contains(cp.Component.Schema.Title)和&ALLOWED_Component_TEMPLATES.Contains(cp.ComponentTemplate.Title)))
{
ok=假;
打破
}
}
返回ok;
}
}

很有趣,因此在页面模板级别(从给定页面检测到)的关系可能比特定页面类型更容易。好吧,Tom.net API似乎没有页面类型或内容类型的类。