Register   Login
     
  Latest Posts  
Front Page Layout
by bmurphy on 8/29/2008 10:20 PM
RE: Tagging
by FBCO on 8/29/2008 8:20 PM
RE: Redesigning Elements of News Articles
by SteveJ on 8/29/2008 7:33 PM
RE: Redesigning Elements of News Articles
by makkabokka on 8/29/2008 7:20 PM
RE: Redesigning Elements of News Articles
by pspeth on 8/29/2008 5:51 PM
RE: Redesigning Elements of News Articles
by smcculloch on 8/29/2008 3:42 PM
RE: Sorry you have to be logged in
by smcculloch on 8/29/2008 3:40 PM
Sorry you have to be logged in
by albertramsbottom on 8/29/2008 3:37 PM
RE: Maximum photo upload
by marshal on 8/29/2008 2:08 PM
RE: Maximum photo upload
by smcculloch on 8/29/2008 2:04 PM
  Forums  
Subject: DNN Core API Optimizations & Caching to Improve URL Rewrite
Prev Next
You are not authorized to post a reply.

Author Messages
Jason KoskimakiUser is Offline
Registered Users
Nuke Wiz
Nuke Wiz
Posts:194

7/08/2006 2:45 PM  

I have customized my own solution that now allows for

mysite com/events/23/softball-game.aspx

From looking at the code, it looks like there are some DNN limitations which makes the code seem somewhat bulky for determining the portalID and tabID. Could there be caching improvements made where for example the portalID, tabID and tabName (and perhaps portal alias or tabpath) are all stored in a cached lookup table? And so users could have direct calls rather than having to write the code to getAllTabs() and do searches on that manually?

Also, the solution I went with (somewhat messy without good core api I suggested above) is where I have a list of predetermined names to match on and corresponding tabnames.  If any of those names appear after the portal alias, they automatically take precedence. And so for instance, I matched on "events" and so sent my url to the events tab. But also I match "restaurants", "bars", "clubs", "locations" all on my "locations" tab. So I can have this

mysite com/restaurants/44/chinese-place.aspx

mysite com/clubs/23/super-dance-club.aspx

mysite com/locations/23/super-dance-club.aspx

Here is my messy function I created in urlrewritemodule.vb that works for me but may not be the prettiest:

        Private Function checkYAPTabPath(ByVal tabpath As String, ByVal yapToken As String, ByVal directedTab As String) As String
                 tabpath = tabpath.Replace("//", "/")

            Dim locSplit As String()
            locSplit = tabpath.Split("/".ToCharArray)
            If locSplit.Length > 2 Then
                tabpath = "//" & locSplit(1) & "//" & locSplit(locSplit.Length - 1)
                tabpath = tabpath.Substring(0, tabpath.LastIndexOf("//")).Replace("//" & yapToken, "") & "//" & directedTab
            Else
                tabpath = "//" & locSplit(1)
            End If
            Return tabpath
        End Function

and here is corresponding function calls in  IdentifyByTabPath():


        Private Function IdentifyByTabPath(ByVal app As HttpApplication) As Boolean

            Dim domain As String = ""
            Dim url As String = app.Request.Url.ToString()

            If (url.ToLower().StartsWith("http://")) Then
                url = url.Replace("http://", "")
            End If

            ' Remove QueryString if it exists
            If (app.Request.Url.Query <> "") Then
                url = url.Replace(app.Request.Url.Query, "")
            End If

            Dim splitUrl() As String = url.Split(Convert.ToChar("/"))

            Dim myAlias As String = ""
            If (splitUrl.Length > 0) Then
                For Each urlPart As String In splitUrl

                    If (myAlias = "") Then
                        myAlias = urlPart
                    Else
                        myAlias = myAlias & "/" & urlPart
                    End If

                    Dim objPortalAlias As PortalAliasInfo = PortalSettings.GetPortalAliasInfo(myAlias)
                    If Not objPortalAlias Is Nothing Then
                        Dim portalID As Integer = objPortalAlias.PortalID

                        ' Identify Tab Name

                        Dim tabPath As String = url.Replace(myAlias, "").ToLower()

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

                        If (tabPath = "/login.aspx") Then
                            RewriterUtils.RewriteUrl(app.Context, "~/" & glbDefaultPage & "?portalid=" & portalID.ToString() & "&ctl=login")
                            Return True
                        End If

                        If (tabPath = "/register.aspx") Then
                            RewriterUtils.RewriteUrl(app.Context, "~/" & glbDefaultPage & "?portalid=" & portalID.ToString() & "&ctl=Register")
                            Return True
                        End If

                        If (tabPath = "/terms.aspx") Then
                            RewriterUtils.RewriteUrl(app.Context, "~/" & glbDefaultPage & "?portalid=" & portalID.ToString() & "&ctl=Terms")
                            Return True
                        End If

                        If (tabPath = "/privacy.aspx") Then
                            RewriterUtils.RewriteUrl(app.Context, "~/" & glbDefaultPage & "?portalid=" & portalID.ToString() & "&ctl=Privacy")
                            Return True
                        End If

                        tabPath = tabPath.Replace("/", "//")
                        tabPath = tabPath.Replace(".aspx", "")


                        tabPath = Me.checkYAPTabPath(tabPath, "locations", "mycity")
                        tabPath = Me.checkYAPTabPath(tabPath, "restaurants", "mycity")
                        tabPath = Me.checkYAPTabPath(tabPath, "clubs", "mycity")
                        tabPath = Me.checkYAPTabPath(tabPath, "bars", "mycity")

I'm waiting to release it on my site and will send a link so you can see it live when I do. It's is SOOOO nice to finally replace tabid/344/ctl/details/mid/23/eventid/455/myevent-name.aspx with /events/455/myevent-name.aspx.

Although, I also if I wanted could have done the control handling myself and done

tabid/344/eventid/455/myevent-name.aspx but I love /events/455/myevent-name.aspx much better!

Jason

ps: I generate my own URL strings without using navigateurl()


Social Networking Site for Young Professionals - My DNN Site w/ lots of Ventrian Modules
You are not authorized to post a reply.
Forums > Projects > Friendly Urls > DNN Core API Optimizations & Caching to Improve URL Rewrite



ActiveForums 3.7