This project is read-only.

How to 'access' a field token @ auto route pattern

Topics: Customizing Orchard, Troubleshooting, Writing modules
Jul 23, 2012 at 9:41 AM
Edited Jul 23, 2012 at 10:34 AM

I have a token for my custom 'dropdowntextfield' but I forgot how to use it.

The token is "SelectedValue" and is defined for 'DropDownTextField'.

I had it working in the past, but I forgot how you need to access it from an auto route pattern :/

edit: or tell me how to use the 'TextField.Length' token as I based my token on that.

Jul 23, 2012 at 11:32 AM

Ok I solved it by extending the correct ITokenProvider interface.

May I tell you that the fact that there are 5 ITokenProvider interfaces makes it very hard to understand things :s

Jul 23, 2012 at 7:28 PM

That's a way to make the coupling between modules very loose.

Jul 24, 2012 at 4:20 PM

The ITokenProvider is inheriting from IEventHandler, which means this interface will act as an event bus. In Orchard when you declare a dependency on something inheriting from IEventHandler, you will get a face implementation (dynamic proxy) which will try to resolve anything which has the same name. It's like saying call this method on anything which signature is the same.

That's why in other modules than Orchard.Tokens we also declare ITokenProvider, so that when the real module call ITokenProvider.XXX then all those implementation are resolved and called, but the Orchard.Tokens module doesn't have to know about them, and those implementations are never called if the Tokens module is not activated.