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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesToken ReplacementToken Replacement
Previous
 
Next
New Post
11/12/2011 9:54 AM
 
Hi,

I'm hoping someone can give me some advice, I'm trying to implement a token replacement for a module, I've never developed one before although i'm familiar to some extent with .Net and VB

I have been following the tutorials Here, Here and in Mitchel Sellers book, but i can't seem to get it to work no matter what i try.

Basically it is returning system tokens like datetime but utterly refuses to callthe GetProperty function that contains my custom functions.

the only thing i can see that i did differently from the book is to create a class called "functions" rather than include code in the information object, but that should surely still work?

can anyone give me any idea why this might be?

many thanks,

John.

oh, the version is dnn 5.06.02
 
New Post
11/13/2011 12:58 PM
 
John,

Can you post some sample of the code that you have written thus far?

It might be hard to figure out without seeing a bit of code.

-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
11/14/2011 12:41 PM
 
Hi,

Thanks for such a quick reply especially at the weekend.

I created the module through the CMS, then added a settings file and a vb class through visual studio which it added to the app code folder. i did this before getting the book! the module is simply 3 files, main ascx, settings.ascx and the functions class.

functions code is as follows:

Imports Microsoft.VisualBasic
Imports DotNetNuke.Services.Tokens
Imports DotNetNuke
Imports DotNetNuke.Entities.Modules



Namespace DotNetNuke.Modules.UP
Public Class UPTokenReplaceFunctions
Implements IPropertyAccess
Public Function GetProperty(ByVal strPropertyName As String, ByVal strFormat As String, ByVal formatProvider As System.Globalization.CultureInfo, ByVal AccessingUser As Entities.Users.UserInfo, ByVal AccessLevel As Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements Services.Tokens.IPropertyAccess.GetProperty
Dim OutputFormat As String = String.Empty
Dim PortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings
If strFormat = String.Empty Then
OutputFormat = "D"
Else
OutputFormat = strFormat
End If
Select Case (strPropertyName.ToLower)
Case "email"
Return "EMAIL GOES HERE"
Case Else
Return "ooh, what happened here then?"
End Select
End Function

Public ReadOnly Property Cacheability As Services.Tokens.CacheLevel Implements Services.Tokens.IPropertyAccess.Cacheability
Get
Return CacheLevel.fullyCacheable
End Get
End Property
End Class

Public Class UPTokenReplace
Inherits Services.Tokens.TokenReplace
Public Sub New(ByVal Functions As UPTokenReplaceFunctions)
MyBase.New(Services.Tokens.Scope.DefaultSettings)
Me.UseObjectLessExpression = True
Me.PropertySource(ObjectLessToken) = Functions
End Sub

Protected Overrides Function replacedTokenValue(ByVal strObjectName As String, ByVal strPropertyName As String, ByVal strFormat As String) As String
Return MyBase.replacedTokenValue(strObjectName, strPropertyName, strFormat)
End Function

Public Function ReplaceUPTokens(ByVal strSourceText As String) As String
Return MyBase.ReplaceTokens(strSourceText) & "StrSource = " & strSourceText
End Function
End Class
End Namespace



and is called from the main file as

lbl2.Text ReplaceTokens.ReplaceUPTokens("[email]")

I'm wondering if the problem is to do with not having controlled the module.

Any advice would be most appreciated!

many thanks,

John.
 
New Post
11/14/2011 9:07 PM
 
John, AFAIR objectless tokens always need to be capitalized.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
11/16/2011 6:31 AM
 
Ah, that's working a lot better!

In all the articles I've read it suggests always comparing strings as lower case, so i assumed tokens could be lower case. also, the system tokens seem to work as lowercase.

Thanks for your help, it'll do what i want now and i can experiment some more with it in the future.

Cheers,

John
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesToken ReplacementToken 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