这与此XSLT问题类似,但最终适用于DWT。
我们可以买到一辆通过C#关键字的密钥。
ItemFields fields = new ItemFields(component.Metadata, component.Schema);
KeywordField keywordField = fields["state"] as KeywordField;
String stateValue = package.EvaluateExpression("Component.Metadata.state");
package.PushItem("statekey", package.CreateStringItem(ContentType.Text, keywordField.Value.Key));在DWT中,我有时需要组件中选定关键字的key。
正在添加并从包中获取正确的方法?
@@Component.Metadata.State@@给了我这个价值。直接从DWT引用键是很好的,但是我还没有看到任何提示DWT公开它的东西。
发布于 2012-09-20 12:02:24
作为约翰回答的另一种选择。对Will的"Get组件模板Uris“(Get Component Template Uris)采用类似的方法,编写一个TBB来迭代某个类别的关键字,并将它们写入具有所需输出值的包中如何?然后,您就可以直接从DWT中使用这些值,并使用“双重评估”,例如:
@@Keyword${Component.Metadata.state}Value@@发布于 2012-09-20 09:48:39
为此,我怀疑您需要按照您的建议沿着TBB路线前进,甚至需要编写您自己的DWT函数来公开它。
您可以在这里找到一个创建DWT函数的示例:http://www.tridiondeveloper.com/get-and-set-variables-in-dwts
https://stackoverflow.com/questions/12509454
复制相似问题