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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Double Token replacementDouble Token replacement
Previous
 
Next
New Post
5/7/2009 11:12 AM
 

I have the situation that i need to send the user an emailmessage. This message contains data from two collections, so what i wanted to do was implement the tokenreplacement twice. How do i replace the the tokens in the first replacement without removing the tokens for the second one?

 

 

TokenReplaceCredits tokenReplaceCredits = new TokenReplaceCredits(Credits);

TokenReplaceAdvertiser tokenReplaceAdvertiser = new TokenReplaceAdvertiser(Advertiser);

 

// Replace Credits Tokens

output.Append(tokenReplaceCredits.ReplaceAdTokens(emailMessage));

  //Replace Advertiser Tokens

output.Append(tokenReplaceAdvertiser.ReplaceAdTokens(output.ToString()));

My emailmessage string contains:

[CreditInfo:AMOUNT]
[AdvertiserInfo:NAME]

 
New Post
5/7/2009 1:51 PM
 

no, you need to implement iPropertyAccess interface (GetProperty method) for both objects (credits and Advertiser) and create an overload of TokenReplace, overriding instatiation and setpropertysource. See Announcements module source code for example.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
5/8/2009 3:39 AM
 

Sebastian Leupold wrote
 

no, you need to implement iPropertyAccess interface (GetProperty method) for both objects (credits and Advertiser) and create an overload of TokenReplace, overriding instatiation and setpropertysource. See Announcements module source code for example.

I allready implemented  iPropertyAccess and created an overload, It already works... The problem is when i run the tokenreplace the first time (with creditinfo object) It replaces all the [CreditInfo:TEST] items perfectly, what i don't want is that it replaces the [AdvertiserInfo:Test] tokens... So i can feed the output from the first... To the second token replacement (Advertiser) Otherwise i need to mess up one of the info classes so it contains the tokens of both the objects (Which i don't really want). 

 
New Post
5/8/2009 7:31 AM
 

I changed the the replacedTokenValue function so that is just replaces for example the [CreditInfo:ITEM] and leaves the other ones... If there is a better solution please let me know

  public class TokenReplaceCredits : TokenReplace
    {
        public TokenReplaceCredits(CreditInfo credit)
            : base(DotNetNuke.Services.Tokens.Scope.DefaultSettings)
        {
            this.UseObjectLessExpression = true;
            //this.PropertySource[ObjectLessToken] = credit;
            this.PropertySource["creditinfo"] = credit;
        }

        protected override string replacedTokenValue(string strObjectName, string strPropertyName, string strformat)
        {
            //return base.replacedTokenValue(strObjectName, strPropertyName, strformat);

            if (strObjectName.ToLower().Equals("creditinfo"))
            {
                return base.replacedTokenValue(strObjectName, strPropertyName, strformat);
            }
            else
            {
                return string.format("[{0}:{1}]", strObjectName, strPropertyName);
            }

            /*string result = string.Empty;
            if (strformat == string.Empty) strformat = "g";
            if (strObjectName.ToLower() == "datetime")
            {
                if (strPropertyName.ToLower() == "today")
                {
                    result = System.DateTime.Today.ToString(strformat);
                }
                else
                {
                    result = System.DateTime.Now.ToString(strformat);
                }
            }
            return result;*/
        }

 
New Post
5/8/2009 9:36 AM
 

you shoul create a class

public class TokenReplaceCreditsAndAdvertiser : TokenReplace
 

where both objects are replaced. Make sure, NOT to use objectless TokenReplace, this is intended for tokens w/o object prefix, like in Announcement Skinning.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Double Token replacementDouble Token replacement


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