4

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?

Nick Albrecht
  • 16,607
  • 10
  • 66
  • 101

1 Answers1

2

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.

Brandon Joyce
  • 3,100
  • 24
  • 25