Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Custom TokensCustom Tokens
Previous
 
Next
New Post
7/27/2010 8:22 PM
 
Ok then, thanks for your response.
 
New Post
10/30/2013 12:28 AM
 
Sebastian - I'm on DNN 7.1.2 and looking for a way to create a custom token per each portal that the HTML module will replace. I understand the DNN list of tokens, but this thread infers that there is a way to create a per-portal custom token replacement process. True?

Could you point me to a step-by-step?
 
New Post
10/30/2013 6:12 AM
 
Daniel, AFAIK the DNN Core does not provide an option to extend portal tokens, but I will need to check out, whether all PortalSettings get provided as portal properties automatically,.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
10/30/2013 6:52 AM
 

Sebastian,
an extensible token-replace provider would be great, would it be possible to add this to DNN?

I imagine a provider that could process tokens in any module's content, and that can be extended with custom tokens - something like wordpress shortcodes.

Bad idea?


 

 
New Post
10/30/2013 1:40 PM
 

This conversation pop ups every couple of months - in varying forms - but the question that is never really fully explored is how it could ever really work for a whole page.

Because of the complexities of the asp.net page cycle - and the lack of any suitable event that can be utilised AFTER the page html is fully rendered - the only real way for such a system to work  is to intercept the HTML as it is rendered by asp.net and apply token replace rules at that stage.  

But there are a number of issue with this:
Firstly it does require a change to the dnn core - something like the following code in default.aspx.cs.

The second issue is one of performance - by the time a page is rendered the size of the HTML can be considerable - so it can take time to process thru the HMTL and replace tokens - using a string builder can help here considerably - but it would still be a hit on heavy servers.

And the final issue - is to ensure that the session state does not become corrupted - a token replace on a session state value will mess your page cycle no end.

As a thought bubble the code is a place to start - is it practical - im guessing not for most people.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected override void Render (HtmlTextWriter twMaster)
{
if (PortalSettings.UseGlobalTokens)
{
     // create a temporary string buider
     StringBuilder sbTemp = new StringBuilder();

    // define a temporary textwriter and attach the string builder as its IO stream 
    HtmlTextWriter twTemp = new HtmlTextWriter(newSystem.IO.StringWriter( sbTemp ));

    // force ASP.NET to render the page to the temporary textwriter twTemp instead of the default twMaster stream
    base.Render( twTemp  );

    //  perform global tokenisation here using the results of sbTemp
    GlobalTokenise( sbTemp ):

    //Finally output the tokenised string to the default textwriter 
    twMaster .Write(  sbTemp.ToString() );
}
else
{
    // just let asp.net do what it normally does if tokens are disabled
    base.Render( twMaster );

}

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

But hey - for what its worth - this is pretty much the code I implemented for a custom site that wanted a lot of global replace type functionality across blogs and articles and other modules and even on the skin and inside containers (dont ask)

Would be interested on other peoples thoughts and ideas on this.

Westa

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Custom TokensCustom Tokens


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.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out