我应该如何从 DWT 获取 Keyword Key [英] How should I get Keyword Key from DWT

查看:21
本文介绍了我应该如何从 DWT 获取 Keyword Key的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这类似于这个 XSLT 问题,但最终是针对 DWT.

This is similar to this XSLT question, but ultimately for DWT.

我们可以通过 C#'sa 关键字获得

We can get a keyword's key via a C# TBB.

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.

In DWT, I sometimes want the key of a selected keyword in a component.

从包中添加和获取这些是正确的方法吗?

@@Component.Metadata.State@@ 获取我的价值.直接从 DWT 引用密钥会很棒,但我没有看到任何迹象表明 DWT 会公开它.

@@Component.Metadata.State@@ gets me the value. Referencing the key directly from DWT would be great, but I haven't seen anything to suggest DWT exposes it.

推荐答案

作为 John 答案的另一种选择.如何采用与 Will 的获取组件模板 Uris"类似的方法并编写一个 TBB 来迭代类别的关键字并将它们写入具有所需输出值的包中?然后,您可以直接从 DWT 使用这些值,并进行双重评估",例如:

As another alternative to John's answer. How about taking a similar approach to Will's "Get Component Template Uris" and write a TBB that iterates over a category's keywords and writes them out into the package with the desired output value? You'd then be able to use these values directly from DWT with a "double-evaluation" like:

@@Keyword${Component.Metadata.state}Value@@

这篇关于我应该如何从 DWT 获取 Keyword Key的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆