Portal Engine
Version 3.x > Portal Engine > Custom Horizontal Menu View modes: 
User avatar
Member
Member
caspian_softdev-yahoo - 9/15/2008 12:39:28 PM
   
Custom Horizontal Menu
hi
how we can add our custom menu in our web site?This menu have image for each menu item.is it possible?how?

thanks

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/16/2008 1:53:16 AM
   
RE:Custom Horizontal Menu
Hi,

Here you can see an example how to integrate third party menu to Kentico CMS - http://devnet.kentico.com/Knowledge-Base/API-and-Internals/Integrating-3rd-party-components-in-Kentico-CMS.aspx

Moreover, if you develop your menu as a standard .Net user control (or server control), you can just add it to the CMS and register it (e.g. for portal engine you need to register this control as a web part and add it in the Site Manager -> Development -> Web parts section). Please note: you may need to use our API to get some important data (e.g. path, nodeID, etc. )

Best Regards,
Juraj Ondrus

User avatar
Member
Member
caspian_softdev-yahoo - 9/17/2008 7:57:45 AM
   
RE:Custom Horizontal Menu
Hi
i see ur guid and i do same way except that i work with vb.net.
in vb.net i get this error :
[Error loading the WebPart 'AspxMenu']
c:\Inetpub\wwwroot\KenticoCMS\CMSWebParts\MyWebParts\TACMenu.ascx.vb(23): error BC30002: Type 'CMSBaseProperties' is not defined.

my code is:
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Imports CMS.PortalControls
Imports CMS.Controls
Imports CMS.DataEngine
Imports CMS.GlobalHelper
Imports CMS.IDataConnectionLibrary
Imports CMS.CMSHelper
Imports CMS.ExtendedControls
Imports CMS.TreeEngine

Partial Class CMSWebParts_MyWebParts_TACMenu
Inherits CMSAbstractWebPart
Public prop As CMSMenuProperties = New CMSBaseProperties

how i can solve this problem or what is a namespace of CMSBaseProperties?

thanks

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/17/2008 8:04:58 AM
   
RE:Custom Horizontal Menu
Hi,

I am sorry but I am confused. This class is in CMS.Controls namespace. But in the example is this class not used. So I do not know what are your trying to achieve. Could you please describe it more?


Best Regards,
Juraj Ondrus

User avatar
Member
Member
caspian_softdev-yahoo - 9/17/2008 8:19:59 AM
   
RE:Custom Horizontal Menu
i send u all my work.
i want to add Devexpress 8.1 menu into my project.
my programming language is vb

problem is that an error ocoures for this line of code

Public prop As CMSMenuProperties=New CMSBaseProperties

"type CMSBaseProperties is not defined"

Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Imports CMS.PortalControls
Imports CMS.Controls
Imports CMS.DataEngine
Imports CMS.GlobalHelper
Imports CMS.IDataConnectionLibrary
Imports CMS.CMSHelper
Imports CMS.ExtendedControls
Imports CMS.TreeEngine

Partial Class CMSWebParts_MyWebParts_TACMenu
Inherits CMSAbstractWebPart
Public prop As CMSMenuProperties=New CMSBaseProperties

#Region "Public properties"


'/// <summary>
'/// Gets or sets the class names
'/// </summary>
Public Property ClassNames() As String
Get
Return DataHelper.GetNotEmpty(ValidationHelper.GetString(Me.GetValue("Classnames"), Me.prop.ClassNames), Me.prop.ClassNames)

End Get
Set(ByVal value As String)
Me.SetValue("ClassNames", value)
Me.prop.ClassNames = value
End Set
End Property


Public Property CombineWithDefaultCulture() As Boolean
Get
Return ValidationHelper.GetBoolean(Me.GetValue("CombineWithDefaultCulture"), Me.prop.CombineWithDefaultCulture)
End Get
Set(ByVal value As Boolean)
Me.SetValue("CombineWithDefaultCulture", value)
Me.prop.CombineWithDefaultCulture = value
End Set
End Property


Public Property CultureCode() As String
Get
Return DataHelper.GetNotEmpty(ValidationHelper.GetString(Me.GetValue("CultureCode"), Me.prop.CultureCode), Me.prop.CultureCode)
End Get
Set(ByVal value As String)
Me.SetValue("CultureCode", value)
Me.prop.CultureCode = value
End Set
End Property


Public Property MaxRelativeLevel() As Int32
Get
Return ValidationHelper.GetInteger(Me.GetValue("MaxRelativeLevel"), Me.prop.MaxRelativeLevel)
End Get
Set(ByVal value As Int32)
Me.SetValue("MaxRelativeLevel", value)
Me.prop.MaxRelativeLevel = value
End Set
End Property



Public Property orderBy() As String
Get
Return DataHelper.GetNotEmpty(ValidationHelper.GetString(Me.GetValue("OrderBy"), Me.prop.OrderBy), Me.prop.OrderBy)
End Get
Set(ByVal value As String)
Me.SetValue("OrderBy", value)
Me.prop.OrderBy = value
End Set
End Property


Public Property Path() As String
Get
Return DataHelper.GetNotEmpty(ValidationHelper.GetString(Me.GetValue("Path"), Me.prop.Path), Me.prop.Path)
End Get
Set(ByVal value As String)
Me.SetValue("Path", value)
Me.prop.Path = value
End Set
End Property


published
Public Property SelectOnlyPublished() As Boolean
Get
Return ValidationHelper.GetBoolean(Me.GetValue("SelectOnlyPublished"), Me.prop.SelectOnlyPublished)
End Get
Set(ByVal value As Boolean)
Me.SetValue("SelctOnlyPublished", value)
Me.prop.SelectOnlyPublished = value
End Set
End Property


Public Property SiteName() As String
Get
Return DataHelper.GetNotEmpty(ValidationHelper.GetString(Me.GetValue("SiteName"), Me.prop.SiteName), Me.prop.SiteName)
End Get
Set(ByVal value As String)
Me.SetValue("SiteName", value)
Me.prop.SiteName = value
End Set
End Property


Public Property WhereCondition() As String
Get
Return DataHelper.GetNotEmpty(Me.GetValue("WhereCondition"), Me.prop.WhereCondition)
End Get
Set(ByVal value As String)
Me.SetValue("WhereCondition", value)
Me.prop.WhereCondition = value
End Set
End Property



#End Region

Protected Sub SetupControl()
If (Me.StopProcessing) Then

Me.prop.StopProcessing = True
Else
' Initialize the CMSMenuProperties object
prop.ParentControl = Me
prop.Path = Me.Path
prop.WhereCondition = Me.WhereCondition
prop.SiteName = Me.SiteName
prop.SelectOnlyPublished = Me.SelectOnlyPublished
prop.OrderBy = Me.orderBy
prop.CultureCode = Me.CultureCode
prop.CombineWithDefaultCulture = Me.CombineWithDefaultCulture
prop.ClassNames = Me.ClassNames
prop.MaxRelativeLevel = Me.MaxRelativeLevel


prop.ClassNames = "CMS.MenuItem"

prop.DataSource = prop.GetDataSource()

Dim topNodeLevel As Int32 = ValidationHelper.GetInteger(prop.DataSource.Tables(0).Rows(0)("NodeLevel"), 0)

For Each dr As DataRow In prop.DataSource.Tables(0).Rows

If (ValidationHelper.GetInteger(dr("NodeLevel"), 0) = topNodeLevel) Then

'Get menu item nodeid (to get the child items)
Dim nodeId As Int32 = ValidationHelper.GetInteger(dr("NodeID"), 0)

' Create menu item, add it to menu and populate it with subitems
Dim child As New DevExpress.Web.ASPxMenu.MenuItem
child = CreateItem(dr)

menuMain.Items.Add(child)
PopulateMenuItem(nodeId, child)


If dr("DocumentName").ToString() = "Services" Or dr("DocumentName").ToString() = "Images" Then

'child.SubMenuStyle. = ComponentArt.Web.UI.GroupOrientation.Horizontal


If (dr("DocumentName").ToString() = "Images") Then

child.SubMenuStyle.ItemSpacing = 10
End If
End If

' Sample code end

Else

Exit For
End If
Next

End If
End Sub

Private Function CreateItem(ByVal dr As DataRow) As DevExpress.Web.ASPxMenu.MenuItem


Dim mnuItem As DevExpress.Web.ASPxMenu.MenuItem = New DevExpress.Web.ASPxMenu.MenuItem

' Set menu caption
mnuItem.Text = GetMenuText(dr)

' Set URL
Dim url As String = GetURL(dr)
If (String.IsNullOrEmpty(GetURL(dr))) Then
' Disable item if there is no URL
mnuItem.Enabled = False
Else
mnuItem.NavigateUrl = url
End If

mnuItem.Image.Url = GetImageURL(dr, "", False, False)



mnuItem.Menu.CssClass = GetCSSClass(dr, False, True)



If (dr("DocumentNamePath").ToString().Contains("Images") And dr("DocumentName").ToString() <> "Images") Then
' Get menu item teaser
If (dr.Table.Columns.Contains("MenuItemTeaserImage")) Then
mnuItem.Image.Url = "getattachment/" + dr("MenuItemTeaserImage").ToString() + "/" + dr("NodeName") + ".aspx?height=100&width=120"
End If

End If


Return mnuItem

End Function

Private Sub PopulateMenuItem(ByVal parentNodeId As Int32, ByVal parent As DevExpress.Web.ASPxMenu.MenuItem)
Dim items As ArrayList = prop.GroupedDS.GetGroup(parentNodeId)
If (items IsNot Nothing) Then
For Each dr As DataRow In items
Dim nodeId As Int32 = ValidationHelper.GetInteger(dr("NodeID"), 0)
Dim child As DevExpress.Web.ASPxMenu.MenuItem = CreateItem(dr)
PopulateMenuItem(nodeId, child)
parent.Items.Add(child)
Next
End If
End Sub

Private Function GetURL(ByVal dr As DataRow) As String
Dim url As String
If (ValidationHelper.GetBoolean(dr("DocumentMenuItemInactive"), False)) Then
url = ""
ElseIf (ValidationHelper.GetString(dr("DocumentMenuRedirectUrl"), "").Trim() <> "") Then
url = ResolveUrl(dr("DocumentMenuRedirectUrl").ToString())
Else
url = prop.GetItemUrl(ValidationHelper.GetString(dr("NodeAliasPath"), ""), ValidationHelper.GetString(dr("DocumentUrlPath"), ""), (dr("NodeLinkedNodeID") IsNot DBNull.Value))
End If
url = HttpContext.Current.Server.UrlPathEncode(url)
Return url
End Function

Private Function GetMenuText(ByVal dr As DataRow) As String


Dim text As String

' If DocumentMenuCaption is not specified, use DocumentName field
If ((Not dr.Table.Columns.Contains("DocumentMenuCaption")) Or (dr("DocumentMenuCaption") Is DBNull.Value) Or (dr("DocumentMenuCaption").ToString() = "")) Then

text = dr("DocumentName").ToString()

Else

text = dr("DocumentMenuCaption").ToString()
End If

Return text

End Function

Private Function GetImageURL(ByVal dr As DataRow, ByVal type As String, ByVal hoverImage As Boolean, ByVal activeImage As Boolean) As String

' Ensure correct type (if type parameter is wrong, then use centre image)
If type = "" Then
type = ""
Else
type = type.ToLower
End If
If (type <> "right" And type <> "left") Then
type = ""
End If

' Get correct Column name
Dim columnname As String = "DocumentMenuItem" + type + "Image" + (IIf(hoverImage, "Over", ""))

If (Not hoverImage And activeImage) Then
columnname += "Highlighted"
End If

' Get URL
Dim url As String = dr(columnname).ToString()

' If there is no image return null otherwise retrun the url
'return (url = "" ? null : url)
Return IIf(url = "", Nothing, url)
End Function

Private Function GetCSSClass(ByVal dr As DataRow, ByVal hoverImage As Boolean, ByVal activeImage As Boolean) As String


' Get correct Column name
Dim columnname As String = "DocumentMenuClass" + (IIf(hoverImage, "Over", ""))
If (Not hoverImage And activeImage) Then
columnname += "Highlighted"
End If

' Get name
Dim name As String = dr(columnname).ToString()

' If there is no class return null otherwise retrun the name
Return (IIf(name = "", Nothing, name))

End Function

Public Overrides Sub OnContentLoaded()
MyBase.OnContentLoaded()
SetupControl()
End Sub

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
prop = New CMSBaseProperties
End Sub
End Class

User avatar
Member
Member
caspian_softdev-yahoo - 9/18/2008 1:40:55 AM
   
RE:Custom Horizontal Menu
problem solved , instead of this line
Public prop As CMSMenuProperties=New CMSBaseProperties
i use
Public prop As CMSMenuProperties = New CMS.Controls.CMSMenuProperties

then problem solve

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/18/2008 1:52:26 AM
   
RE:Custom Horizontal Menu
Hi again,

I am sorry for the delay. The problem was that you cannot implicitly convert type 'CMS.Controls.CMSBaseProperties' to 'CMS.Controls.CMSMenuProperties'.

Now it should be working fine.

Best Regards,
Juraj Ondrus