Hi all,
In the latest versions of DNN there is a interface to create custom token repleacemet provider. I want to creat my custom token replacement provider. Are the any examples of this or is there any documentation on how to implement this?
Hi Joe, I've been looking into that too, recently. It looks like you can just create your own TokenProvider class, make it inherit DotNetNuke.Services.Tokens.TokenProvider and register it in web dot config as the default one.
public class JoesTokenProvider : TokenProvider { /// public override bool ContainsTokens(string content, TokenContext context) { return false; // already determined by BaseCustomTokenReplace } /// public override string Tokenize(string content, TokenContext context) { var tokenizer = new TokenReplace { TokenContext = context }; return tokenizer.ReplaceEnvironmentTokens(content); } }
Then you can implement it however you want to implement it.
But I haven't tried it yet myself either...
Greetz, Stefan
Sounds cool!
From what version on is 'Latest versions'? And where does it reside?
So...is there some example somewhere that you know of that actually
- uses the standard DNN tokens
- allow you to expand it with your own tokens
I've tried some things (like the suggestions above) but it doesn't seem to be that simple. Indeed if you create a custom provider and register it in webconfig, it will replace the defaultprovider. So it only replaces your own tokens, and not the standard stuff that DNN has built in. And it is not so easy to kind of override the default token provider. So any examples would be great...
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.