version 1.0.3 comes with a few bug fixes, and new cool features, such as environment token support, and dynamic regex variables.
Feel free to download the trial version.
Our module gives full control over the mapping between real and rewritten urls. You define rules made of a customizable vocabulary.
Bringing Friendly Urls to any existing module only requires you to build your own vocabulary with a few lines of code.
Here's a sample implementation for the Dnn forum:
You can see the result on our website. Simply compare the Urls to what you normally get on the dotnetnuke.com forums, and now look what it took to make it.
You only need to declare the new vocabulary you wish to consume and provide corresponding "rewrites".
Public Class DnnForumUrlRewriter
Implements IUrlRewriterProvider
Public Function GetModuleRewrites() As System.Collections.Generic.List(Of GroupParamsRewrite) Implements IUrlRewriterProvider.GetRewrites
Dim toReturn As New List(Of GroupParamsRewrite)
toReturn.Add(New GroupParamsRewrite("GroupName", RewriteType.SubPath, UrlParam.FromSyntax("groupid")))
toReturn.Add(New GroupParamsRewrite("ForumName", RewriteType.SubPath, UrlParam.FromSyntax("forumid")))
toReturn.Add(New GroupParamsRewrite("ThreadName", RewriteType.SubPath, UrlParam.FromSyntax("threadid")))
Return toReturn
End Function
Public Function RewriteParams(ByVal groupName As String, ByVal objRewriteType As RewriteType, ByVal params As System.Collections.Generic.Dictionary(Of UrlParam, String)) As GroupRewriteResult Implements IUrlRewriterProvider.RewriteParams
Dim toReturn As New GroupRewriteResult()
If params.Count > 0 Then
Select Case groupName.ToLowerInvariant
Case "groupname"
Dim groupeId As Integer = Integer.Parse(params(UrlParam.FromSyntax("groupid")), CultureInfo.InvariantCulture)
toReturn.RewriteValue = GetGroupName(groupeId)
toReturn.ConsumedParameters(UrlParam.FromSyntax("groupid")) = True
Case "forumname"
Dim forumId As Integer = Integer.Parse(params(UrlParam.FromSyntax("forumid")), CultureInfo.InvariantCulture)
toReturn.RewriteValue = GetForumName(forumId)
toReturn.ConsumedParameters(UrlParam.FromSyntax("forumid")) = True
Case "threadname"
Dim threadId As Integer = Integer.Parse(params(UrlParam.FromSyntax("threadid")), CultureInfo.InvariantCulture)
toReturn.RewriteValue = GetThreadName(threadId)
toReturn.ConsumedParameters(UrlParam.FromSyntax("threadid")) = True
End Select
End If
Return toReturn
End Function
Public Function GetGroupName(ByVal groupeId As Integer) As String
Dim gc As New DotNetNuke.Modules.Forum.GroupController
Dim GroupInf As DotNetNuke.Modules.Forum.GroupInfo = gc.GroupGet(groupeId)
Dim toReturn As String = String.Empty
If GroupInf IsNot Nothing Then
toReturn = GroupInf.Name
End If
Return StringEscaper.EscapeString(toReturn, 45)
End Function
Public Function GetForumName(ByVal forumId As Integer) As String
Dim fc As New DotNetNuke.Modules.Forum.ForumController
Dim ForumInf As DotNetNuke.Modules.Forum.ForumInfo = fc.GetForum(forumId)
Dim toReturn As String = String.Empty
If ForumInf IsNot Nothing Then
toReturn = ForumInf.Name
Else
toReturn = forumId
End If
Return StringEscaper.EscapeString(toReturn, 45)
End Function
Public Function GetThreadName(ByVal threadId As Integer) As String
Dim tc As New DotNetNuke.Modules.Forum.ThreadController
Dim ThreadInf As DotNetNuke.Modules.Forum.ThreadInfo = tc.ThreadGet(threadId)
Dim toReturn As String = String.Empty
If ThreadInf IsNot Nothing Then
toReturn = ThreadInf.Subject
End If
Return StringEscaper.EscapeString(toReturn, 45)
End Function
End Class
Now here 's the rule associated to our forum: The new vocabulary is instantly available in your specific pattern.
[${Scheme}][${RootPath}][/${Language}][/${TabPath}][/${TabName}][/${ModuleTitle}][/${groupname}][/${forumname}][/${threadname}][/${threadpage}][/${postid}][/${scope}][/${action}][/${ControlKey}][/${Params,SubPath}][.${Extension}][?${QueryString,QueryStringValue}]