Boolean Tokens in Orchard CMS

♀尐吖头ヾ 提交于 2020-01-14 13:16:12

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/15279353/boolean-tokens-in-orchard-cms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!