Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesHow to use DNN tokens in custom modules ?How to use DNN tokens in custom modules ?
Previous
 
Next
New Post
12/15/2014 6:03 AM
 

Hi guys quick one this time.

Anyone know how to make use of DNN tokens in custom modules?

I don't need much just wanted to use [Module:ModuleId] token to define container tag id like so:

<div id="myModule-[Module:ModuleId]">...</div>

Only to find out that that didn't work and token wasn't replaced by a number. At first I thought that the token I tried to reference doesn't exist but then I found this page where it clearly has a place.

I am working on compiled module for DNN 7.3.3

If anyone has a bit of experience with this I would appreciate your input.

 
New Post
12/15/2014 7:24 AM
 

Isa,

if you add the runat="server" attribute to your div tag, you will get something like

<div id="dnn_ctrxxxx_ModuleContent" ... >

(and xxxx is the module ID). But I am sure this is not what you wanted.

To resolve the tokens, you need something in your code behind to replace them from a given text, e.g.

new DotNetNuke.Services.Tokens.TokenReplace().ReplaceEnvironmentTokens(someStringContainingTokens);

Therefore, I don't think that it is possible in an acsx file.

Happy DNNing!
Michael


Michael Tobisch
DNN★MVP
dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
12/15/2014 9:31 AM
 
Michael Tobisch wrote:

Isa,

if you add the runat="server" attribute to your div tag, you will get something like

(and xxxx is the module ID). But I am sure this is not what you wanted.

To resolve the tokens, you need something in your code behind to replace them from a given text, e.g.

new DotNetNuke.Services.Tokens.TokenReplace().ReplaceEnvironmentTokens(someStringContainingTokens);

Therefore, I don't think that it is possible in an acsx file.

Happy DNNing!
Michael

 

Cheers Michael.

Adding runat="server" would do the trick but its not what I want/need.

For now I implemented ModuleId property which is populated out of ModuleContext.ModuleId in code behind file. I suppose this will have to do for now but there seems to be lack of information on how to integrate tokens into custom modules.

As my last resort I had a very brief look at HTML module but all I was able to find is the checkbox on the settings page.

I will have to take a more in depth look when I have a bit more spare time.

 
New Post
12/15/2014 9:48 AM
 
this blog post describes the TokenReplace engine: http://www.dnnsoftware.com/community-...

Cheers from Germany,
Sebastian Leupold (Microsoft MVP)

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
12/15/2014 5:10 PM
 
Hi Isa,

There's a fair amount out there on using the tokens, but I think they just work differently than what you're aiming to do here. Modules don't automatically get their tokens replaced, so, as Michael noted, you'd have to do that yourself in the code and then write the result somehow to the page's output. DNN's token replacement method automatically takes care of most of the "default" tokens, and then you can add any custom tokens you want pretty easily.

It's true that, to do what you're going for here, referencing the module ID is probably easiest. With that said, if you wanted to use tokens, you'd just have to do so in a manner that works with how web forms works (until DNN moves to vnext).

Hope this helps,

Mike
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesHow to use DNN tokens in custom modules ?How to use DNN tokens in custom modules ?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out