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

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Developing DNN custom module/control, wanted to get some DNN tokensDeveloping DNN custom module/control, wanted to get some DNN tokens' values, connection string...
Previous
 
Next
New Post
9/29/2009 4:21 PM
 

Hi All,

I'm developing DNN custom module/control, and in it I wanted to get some DNN tokens' values, my DNN's site main connection string etc. - I prefer to not use "hacking" but get all the necessary information via DNN API: I got information on DNN tokens:

http://dnnprofessor.com/Articles/tabid/223/articleType/ArticleView/articleId/79/PageID/33/Personalizing_the_DNN_TextHTML_Module_Using_Tokens.aspx

and I have got downloaded DNN developers' help file:

http://dnnhelpsystem.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33248

What classes should I investigate first of all to find/dig out how to get DNN tokens' values, connection string?

Are there any code samples available online?

Thank you.

--Shamil

 

 
New Post
9/29/2009 5:12 PM
 

I hope I understand the question.  When I develop a module and allow the use of tokens, they do not come from DNN, I create the list of tokens and then I do the replace within the code or on the database depending on what I am doing.  I do not know of a built in method where I can pass it a token like [USERNAME] and it automatically hands back the username...  I think you will have to do the bulk of the work yourself and then rely on DNN to retrieve the data for a given token (i.e. use request the username from DNN when your code finds the [USERNAME] token in the text etc.  Hopefully I am on the same page and this helps.


Best Regards,

Robert J Collins | Co-Founder & President

Netlogic Corporation

 
New Post
9/29/2009 5:23 PM
 

please be aware, that tokens are used in modules, to provide admins with an option to personalize content accoding to current environment of the user - user itself, module, site, host etc. This is built in by using DotNetNuke.Services.TokenReplace, and may also being used for templating, like been done by Announcements module.

if you need to access DNN data in your module, you get the information directly from DNN API, accessing current module and http context. There are numerous examples in core admin modules and packaged project team modules - I suggest to install source versions and investigate the source code.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
9/30/2009 8:23 AM
 

Thank you, Sebastian.

I do have DNN sources installed but I didn't have a "hook" to start from - your advice helped me - here is what I suppose should be my code to get some context information I needed in my module - could you please have a quick look through it to verify is it good/bad (I haven't compiled/run it - just typed it in notepad following some code from DNN sources):

public class DNNModuleUserContext
{
    private DotNetNuke.Services.Tokens.TokenReplace _tokenizer;
    public DNNModuleContext()
    {
         _tokenizer = new DotNetNuke.Services.Tokens.TokenReplace()
          _tokenizer.AccessingUser = UserController.GetCurrentUserInfo()
          _tokenizer.DebugMessages = false
    }

    public string UserName {
        return _tokenizer.ReplaceEnvironmentTokens("[User:Username]"); }
   
    public string UserName1 {
        return tokenizer.AccessingUser.Username ; }
   
    public int UserId {
        return tokenizer.AccessingUser.UserId ; }
   
    public string[] UserRoles {
        return tokenizer.AccessingUser.UserRoles ; }
   
    public int PortalId {
        return tokenizer.AccessingUser.PortalId ; }
   
    public bool IsSuperUser {
        return tokenizer.AccessingUser.IsSuperUser ; }

    public string TabName {
        return _tokenizer.ReplaceEnvironmentTokens("[Tab:TabName]"); }

    public string GetUserProfileProperty(string propertyName) {
        return _tokenizer.ReplaceEnvironmentTokens(
               string.format("[Profile:{0}]", propertyName)); }
    }
}

Thank you.

--Shamil

 
New Post
9/30/2009 8:25 AM
 

Hi Robert,

Thank you for your reply.

Please have a look at my reply to Sebastian here - the code sample I posted is what I'm looking for I suppose.

--Shamil

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Developing DNN custom module/control, wanted to get some DNN tokensDeveloping DNN custom module/control, wanted to get some DNN tokens' values, connection string...


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