Orchard CMS 中的布尔代币 [英] Boolean Tokens in Orchard CMS
问题描述
假设我在 Orchard CMS 中创建了一个联系我们"表单,其中包含以下字段
<前>名称:电子邮件地址:信息:通讯:现在,在提交此表单时,我已将其设置为通过电子邮件发送特定电子邮件地址,并且我正在使用四个字段的令牌来构建电子邮件,以便收到的电子邮件可能如下所示.
姓名:约翰·史密斯
电子邮件地址: jsmith@example.com
消息:嗨!我喜欢你的网站,希望你能得到更多我将来可以使用的内容!
简报:真实
现在这很好,但最后一个字段 Newsletter
是一个布尔值,我希望这里显示的文本是是/否(或可能是其他自定义词).如何用电子邮件中的默认 True/False 标记值替换自定义标记值?
您可能需要为此实现自己的令牌提供程序.这是 Orchard.Fields 模块的一个例子...... FieldTokens.cs
请注意,这里没有直接引用 Orchard.Tokens 项目,因此它们使用事件总线约定,您可以使用与另一个事件处理程序相同的名称和签名定义自己的接口.Orchard 将看到此约定并将您的实现视为这些事件的处理程序.我只是提到这一点,因为它起初让我感到困惑.如果需要,您可以直接引用令牌模块.
Let say I have a Contact Us form in Orchard CMS that I have created that had the following fields
Name: Email Address: Message: Newsletter:
Now upon submitting this form I have it set to email a specific email address and I'm using the Tokens for the four fields to build the email so that the email received might look like this.
Name: John Smith
Email Address: jsmith@example.com
Message: Hi! I love your site and I hope you get some more content that I can use in the future!
Newsletter: True
Now this is fine, but the last field Newsletter
is a boolean and I'd like the text represented here to be Yes/No (or potentially other custom words). How do I substitute the default True/False token values in the email for custom ones?
You'll probably need to implement your own token provider for this. Here is an example from the Orchard.Fields module... FieldTokens.cs
Note that there is no direct reference to the Orchard.Tokens project here so they use the event bus convention where you can define your own interface with the same name and signature as another event handler. Orchard will see this convention and treat your implementation as a handler for those events. I only mention this because it confused me at first. You can directly reference the tokens module if you want to.
这篇关于Orchard CMS 中的布尔代币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!