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...Language LinksLanguage Links
Previous
 
Next
New Post
10/22/2010 5:36 PM
 
I know that it is an object but when I type it it seems that visual studio does not recognize it. Is there a way to get the url of the current page if I have to language cods like "el-GR"?
 
New Post
10/22/2010 9:26 PM
 
it's because you haven't set the object to be an instance of anything - it's likely the missing code looked a little like "dim localtokenreplace as new dotnetnuke.services.tokens.tokenreplace". As for the part of the path Request.Url.GetLeftPart(UriPartial.Path) will give the path without the querystring parameters, but you probably require those and just want to alter the language so perhaps a string.replace would suffice.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
10/24/2010 1:25 AM
 

I finally found the solution to my problem after serching in dnn source code so I will publish the code here in case that someone else needs to know how to do it. I have one LinkButton for each language and the equivalent events which will handle the language change. In order to make it simple I will type use a simple example with text instead of images but you can replace the word of the langue with an img tag.



The HTML Part



    <asp:LinkButton ID="btnGreek" runat="server" OnClick="btnGreek_Click">Greek</asp:LinkButton>

    <asp:LinkButton ID="btnEnglish" runat="server" OnClick="btnEnglish_Click">English</asp:LinkButton>



The VB.NET code



    Private Function getQSParams(ByVal newLanguage As String) As String()

        Dim returnValue As String = ""

        Dim coll As NameValueCollection = HttpContext.Current.Request.QueryString

        Dim arrKeys(), arrValues() As String

        arrKeys = coll.AllKeys

        For i As Integer = 0 To arrKeys.GetUpperBound(0)

            If arrKeys(i) IsNot Nothing Then

                Select Case arrKeys(i).ToLowerInvariant()

                    Case "tabid", "ctl", "language"

                        'skip parameter

                    Case Else

                        If (arrKeys(i).ToLowerInvariant = "portalid") And PortalSettings.ActiveTab.IsSuperTab Then

                            'skip parameter

                            'navigateURL adds portalid to querystring if tab is superTab

                        Else

                            arrValues = coll.GetValues(i)

                            For j As Integer = 0 To arrValues.GetUpperBound(0)

                                If returnValue <> "" Then returnValue += "&"

                                returnValue += arrKeys(i) + "=" + HttpUtility.HtmlEncode(arrValues(j))

                            Next

                        End If

                End Select

            End If

        Next

        Dim settings As PortalSettings = PortalController.GetCurrentPortalSettings

        If (Not settings.ContentLocalizationEnabled) AndAlso _

                LocaleController.Instance.GetLocales(settings.PortalId).Count > 1 AndAlso _

                (settings.EnableUrlLanguage = False) Then

            'because useLanguageInUrl is false, navigateUrl won't add a language param, so we need to do that ourselves

            If returnValue <> "" Then returnValue += "&"

            returnValue += "language=" + newLanguage

        End If

        'return the new querystring as a string array

        Return returnValue.Split("&"c)

    End Function

   

    Private Function GetURL(ByVal newLanguage As String) As String

        Dim objSecurity As New PortalSecurity

        Dim newLocale As Locale = LocaleController.Instance().GetLocale(newLanguage)

        'Ensure that the current ActiveTab is the culture of the new language

        Dim tabId As Integer = PortalSettings.ActiveTab.TabID

        Dim localizedTab As DotNetNuke.Entities.Tabs.TabInfo = New TabController().GetTabByCulture(tabId, PortalSettings.PortalId, newLocale)

        If localizedTab IsNot Nothing Then

            tabId = localizedTab.TabID

        End If

        Return objSecurity.InputFilter(NavigateURL(tabId, PortalSettings.ActiveTab.IsSuperTab, PortalSettings, HttpContext.Current.Request.QueryString("ctl"), newLanguage, getQSParams(newLanguage)), PortalSecurity.FilterFlag.NoScripting)

    End Function

    Protected Sub btnEnglish_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Response.Redirect(GetURL("en-US"))

    End Sub

    Protected Sub btnGreek_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Response.Redirect(GetURL("el-GR"))

    End Sub



 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Language and In...Language and In...Language LinksLanguage Links


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