gpt4 book ai didi

tridion - 从Razor TBB访问页面模板元数据

转载 作者:行者123 更新时间:2023-12-04 04:22:40 25 4
gpt4 key购买 nike

有谁知道是否可以从Razor TBB中读取页面模板元数据?我正在实现使用960网格系统构建的设计,并且为了保持CT的可重用性,我希望能够执行以下操作:

<div class="@Page.Template.Metadata.content_grid">
</div>

不幸的是,这引发了空引用异常。

我正在尝试执行什么操作?是否需要编写自定义的TBB将此信息添加到程序包中?

最佳答案

在转到Alex的博客提出问题之后,我发现他已经是answered it for someone else了:

Regarding getting Template Metadata out… unfortunately I have not created a wrapper yet for the Template itself, the @Template that is exposed right now is just the Tridion.ContentManager.CommunicationManagement.Template one, which means for now you’ll have to get template fields out the old fashioned way:

@{ Tridion.ContentManager.ContentManagement.Fields.ItemFields templateFields = new ContentManager.ContentManagement.Fields.ItemFields(Template.Metadata, Template.MetadataSchema); }

I’ve added this on my To Do list now though, so you’ll be sure to see a convenience wrapper that will allow you to do @Template.MetaData.YourField in version 1.3.

关于tridion - 从Razor TBB访问页面模板元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10550023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com