Register   Login
     
  Latest Posts  
Private Messages 1.07 - Potential Display Name Bug
by blob150 on 12/03/2008 5:16 PM
Removal of "Actions" section...
by jlatulippe on 12/03/2008 5:08 PM
RE: MultiSelect Search on Multiple Checkbox
by smcculloch on 12/03/2008 3:46 PM
RE: Property Agent Latest Filter
by erikvb on 12/03/2008 3:45 PM
RE: Help! property type error
by smcculloch on 12/03/2008 3:44 PM
RE: Property Agent Latest Filter
by smcculloch on 12/03/2008 3:42 PM
RE: Set default value
by smcculloch on 12/03/2008 3:42 PM
RE: Can an entry belong to multiple types?
by smcculloch on 12/03/2008 3:42 PM
RE: Remove CAPTCHA when logged in?
by smcculloch on 12/03/2008 3:40 PM
RE: Display Name
by smcculloch on 12/03/2008 3:38 PM
  Forums  
Subject: Hardcoding your own Customization
Prev Next
You are not authorized to post a reply.

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

6/27/2006 5:58 PM  

I was wondering if it is possible to hardcode your own customizations. There are instances where you could not do certain things with the url writer because it cannot be made generic. But I was wondering if these customizations below were possible if I were to manually add rules in the urlwriter code:

www mysite com/child/locations/44/joes-steakhouse.aspx

This would goto tabname=locations and the default file there would load locationID 44. So If I see mysite com/child/locations I know to set the tabname to locations.

I would likewise do the same thing like so with events tab....

www mysite com/child/events/144/dinner-at-joes.aspx

I would only add this to the reader side. That is, I would be generating these URL strings manually on my own and just want the urlwriter to read them.

I suppose in this case if this were possible I could also manually do www mysite com/child/events/144.aspx but I like the seo benefit of having the title in the url.

Jason


Social Networking Site for Young Professionals - My DNN Site w/ lots of Ventrian Modules
Scott McCullochUser is Offline
Administrators
Nuke Master
Nuke Master
Posts:12577


6/28/2006 7:18 AM  
Yes, it is possible to add your own customisations, the core rewriter uses a pattern system of looking for a particular type of URL:-

e.g. www.mysite.com/articles/55.aspx

You could add a regex that would search for this, and then rewrite it, the problem is, you also have to come up with a tab of where it is going to, but this could be added to the send to.

You can look at siteurls.config for examples.

The rewriter that I extended, should also look at this file.

You would also have to modify your module to write URLs out like this too.

Scott McCulloch
Site Administrator
Scott McCullochUser is Offline
Administrators
Nuke Master
Nuke Master
Posts:12577


6/28/2006 7:19 AM  
Oh one more thing, if you want to go one step further and have:-

www.mysite.com/articles/some-article.aspx

This would require some additional logic to lookup the article, and couldn't be done solely in the siteurls.config.

Scott McCulloch
Site Administrator
Jason KoskimakiUser is Offline
Registered Users
Nuke Wiz
Nuke Wiz
Posts:194

7/10/2006 7:54 AM  
I succeeded in getting my URLs rewritten. Take a look at:

http://www.yapclub.com/dfw/events/394/monthly-party.aspx

which used to be

http://www.yapclub.com/dfw/tabid/56/ctl/details/mid/369/eventid/394/monthly-party.aspx

Happy days......

Jason

Social Networking Site for Young Professionals - My DNN Site w/ lots of Ventrian Modules
Scott McCullochUser is Offline
Administrators
Nuke Master
Nuke Master
Posts:12577


7/10/2006 8:48 AM  
Hi Jason,

Which method did you use?

Scott McCulloch
Site Administrator
Jason KoskimakiUser is Offline
Registered Users
Nuke Wiz
Nuke Wiz
Posts:194

7/10/2006 11:08 AM  

Here is my messy function I created in urlrewritemodule.vb that works for me but may not be the prettiest. I basically give names to search for and corresponding tabs to direct to. So if the first word after the portal alias matches one of my terms, I redirect to the tabname designated for that term. With that in mind, I can have restaurants, bars, night-clubs, all redirect to my "mycity" tab.

        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")


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 > Hardcoding your own Customization



ActiveForums 3.7