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...Language and In...Language and In...HumanFriendlyUrl on 5.5.1 ML Portals patchHumanFriendlyUrl on 5.5.1 ML Portals patch
Previous
 
Next
New Post
10/20/2010 9:13 AM
 
I wanted the UmanFriendlyUrls were also supported by 5.5.1 for multi-languages sites and I read here on the forum that other users wanted the same.
So I decided to write a patch to make this happen.

The final format of the URL will be: domain/culturecode/tabpath.aspx (http://example.com/en-gb/home.aspx)

The patch consists of a few lines of code that modify two files:

FriendlyUrlProvider (DotNetNuke.HttpModules)

From line 147

Public Overloads Overrides Function FriendlyUrl(ByVal tab As TabInfo, ByVal path As String, ByVal pageName As String, ByVal portalAlias As String) As String

            Dim friendlyPath As String = path
            Dim matchString As String = ""
            Dim isPagePath As Boolean = tab IsNot Nothing

            If (UrlFormat = UrlFormatType.HumanFriendly) Then
                If (tab IsNot Nothing) Then
                    Dim queryStringDic As Dictionary(Of String, String) = GetQueryStringDictionary(path)
                    If (queryStringDic.Count = 0 OrElse (queryStringDic.Count = 1 AndAlso queryStringDic.ContainsKey("tabid"))) Then
                        'Return AddHTTP(portalAlias & "/" & tab.TabPath.Replace("//", "/").TrimStart(Convert.ToChar("/")) + ".aspx")
                        friendlyPath = GetFriendlyAlias("~/" & tab.TabPath.Replace("//", "/").TrimStart("/"c) + ".aspx", portalAlias, isPagePath)
                    ElseIf (queryStringDic.Count = 2 AndAlso queryStringDic.ContainsKey("tabid") AndAlso _
                            queryStringDic.ContainsKey("language")) Then
                        If Not tab.IsNeutralCulture Then
                            friendlyPath = GetFriendlyAlias("~/" & tab.CultureCode & "/" & tab.TabPath.Replace("//", "/").TrimStart("/"c) + ".aspx", portalAlias, isPagePath).ToLower
                        Else
                            friendlyPath = GetFriendlyAlias("~/" & queryStringDic("language") & "/" & tab.TabPath.Replace("//", "/").TrimStart("/"c) + ".aspx", portalAlias, isPagePath).ToLower
                        End If

                    Else
                        If (queryStringDic.ContainsKey("ctl")) AndAlso Not (queryStringDic.ContainsKey("language")) Then
                            Select Case queryStringDic("ctl")
                                Case "terms"
                                    friendlyPath = GetFriendlyAlias("~/terms.aspx", portalAlias, isPagePath)
                                Case "privacy"
                                    friendlyPath = GetFriendlyAlias("~/privacy.aspx", portalAlias, isPagePath)
                                Case "login"
                                    If (queryStringDic.ContainsKey("returnurl")) Then
                                        friendlyPath = GetFriendlyAlias("~/login.aspx?ReturnUrl=" & queryStringDic("returnurl"), portalAlias, isPagePath)
                                    Else
                                        friendlyPath = GetFriendlyAlias("~/login.aspx", portalAlias, isPagePath)
                                    End If
                                Case "register"
                                    If (queryStringDic.ContainsKey("returnurl")) Then
                                        friendlyPath = GetFriendlyAlias("~/register.aspx?returnurl=" & queryStringDic("returnurl"), portalAlias, isPagePath)
                                    Else
                                        friendlyPath = GetFriendlyAlias("~/register.aspx", portalAlias, isPagePath)
                                    End If
                                Case Else
                                    'Return Search engine friendly version
                                    Return GetFriendlyQueryString(tab, GetFriendlyAlias(path, portalAlias, isPagePath), pageName)
                            End Select
                        Else
                            'Return Search engine friendly version
                            Return GetFriendlyQueryString(tab, GetFriendlyAlias(path, portalAlias, isPagePath), pageName)
                        End If
                    End If
                End If
            Else
                'Return Search engine friendly version
                friendlyPath = GetFriendlyQueryString(tab, GetFriendlyAlias(path, portalAlias, isPagePath), pageName)
            End If

            friendlyPath = CheckPathLength(friendlyPath, path)

            Return friendlyPath

        End Function

UrlrewriteModule (DotNetNuke.HttpModules)

line 30
Imports DotNetNuke.Services.Localization

From line 194

' Default Page has been Requested
                            If (tabPath = "/" & glbDefaultPage.ToLower()) Then
                                Return
                            End If

                            'Start of patch
                            Dim CulturCode As String = String.Empty

                            Dim dicLocales As Dictionary(Of String, Locale) = LocaleController.Instance().GetLocales(portalID)
                            If dicLocales.Count > 1 Then
                                For Each CulturePart As String In splitUrl
                                    If CulturePart.Length.Equals(5) Then
                                        For Each key As KeyValuePair(Of String, Locale) In dicLocales
                                            If key.Key.ToLower.Equals(CulturePart.ToLower) Then
                                                CulturCode = key.Value.Code
                                                tabPath = tabPath.Replace("/" & CulturePart, "")
                                                Exit For
                                            End If
                                        Next
                                    End If
                                Next
                            End If

                            ' Check to see if the tab exists (if localization is enable, check for the specified culture)
                            Dim tabID As Integer = TabController.GetTabByTabPath(portalID, tabPath.Replace("/", "//").Replace(".aspx", ""), CulturCode)

                            ' Check to see if neutral culture tab exists
                            If (tabID = Null.NullInteger And CulturCode.Length > 0) Then
                                tabID = TabController.GetTabByTabPath(portalID, tabPath.Replace("/", "//").Replace(".aspx", ""), "")
                            End If

                            'End of patch

                            If (tabID <> Null.NullInteger) Then
                                Dim sendToUrl As String = "~/" & glbDefaultPage & "?TabID=" & tabID.ToString()
                                If Not CulturCode.Equals(String.Empty) Then
.......


I tested it on my local app that contains my productions portals and for me work fine.
There is only a problem with neutral culture tabs, like admins tabs, that, after postback redirect to the wrong culture.
This is due to a 5.5.1 bug.
To fix it you must change  the line 2189 in Library/Common/Globals.vb
From
cultureCode = Thread.CurrentThread.CurrentUICulture.Name
to
cultureCode = Thread.CurrentThread.CurrentCulture.Name

Feel free to test the patch on your local app and to improve it.

Let me know yours opinions.

Regards
Manzoni Fausto
 
New Post
10/20/2010 9:26 AM
 
you may submit your enhancement to the issue tracker at support.dotnetnuke.com, however it may take some time to get taken care of. The best option would be creating an enhanced FriendlyURLProvider package and provide it on codeplex.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
10/20/2010 9:42 AM
 
Sebastian Leupold wrote:
you may submit your enhancement to the issue tracker at support.dotnetnuke.com, however it may take some time to get taken care of. The best option would be creating an enhanced FriendlyURLProvider package and provide it on codeplex.

 Patch submitted here and available for download.

There is only the FriendlyurlProvider and not the bug fixed on dnn.Library.

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Language and In...Language and In...HumanFriendlyUrl on 5.5.1 ML Portals patchHumanFriendlyUrl on 5.5.1 ML Portals patch


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