开发者

Adding Request Parameters to a DotNetNuke page

I'm wondering if there's a simple way to specify a requ开发者_运维问答est parameter (i.e. CategoryID) in the page header section or somehow associated to a particular page that would be picked up by Request("CategoryID")? Or another simple approach to easily specify a Request Parameter for a DotNetNuke page that would be picked up by Request(). We need different pages to have different categoryid's.

Detail We've got a module that appears on every page. It always makes a call to Request("CategoryID") to see if a category is defined for the page, if so, it filters it's results list by that category. Normally this is used when the CategoryID is specified in the URL. But in this case, we want to specify it some other way. I could probably specify a skin object as part of the skin that would look at the URL and map to the appropriate categoryID and write it out as a session variable but I'm looking for a simpler approach.

Any ideas?


I ended up creating a SkinObject that handles this. Currently, I've hard coded the mapping from the TabID to the CategoryID and then I do a Response.Redirect to the page with the CategoryID appended to the URL.

I initially tried writing the CategoryID to the ViewState in the Skin Objects Page.Init but that wasn't getting picked up by the module.

I still think there is a better way (I'm worried about the SEO impact of this) but this is working for now until I come up with something better or add functionality to the module.

NameSpace DotNetNuke.UI.Skins.Controls
Partial Class MapURLToCategoryID
    Inherits UI.Skins.SkinObjectBase

    Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
        If Request("CategoryID") <> "" Then
            Exit Sub
        End If
        Dim id As Int16 = -1

        Select Case Request("tabid")
            Case 92
                id = 14
            Case 93
                id = 15
            Case 227
                id = 38
            Case 95
                id = 19
            Case 91
                id = 13
            Case 226
                id = 17
            Case 94
                id = 16
            Case Else
                'do nothing

        End Select
        If id <> -1 Then
            Response.Redirect(NavigateURL("", "CategoryID=" & id.ToString), False)
        End If

    End Sub
End Class
End Namespace


Adding Request Parameters to a DotNetNuke page

This allows you to store and retrieve CategoryID in the Page's keywords. This would be called upon page load.

        Dim TC As New TabController
        Dim TI As DotNetNuke.Entities.Tabs.TabInfo = TC.GetTab(TabId, PortalId, True)

        Dim tokens() As String = TI.KeyWords.Split(","c)
        For Each token As String In tokens
            Dim tokens2() As String = Trim(token).Split(":"c)
            If tokens2.Length = 2 AndAlso tokens2(0) = "CategoryID" Then
                Response.Write("My CategoryID is " & tokens2(1))
            End If
        Next
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜