CustomAttributes

Return to previous page

  • 4/7/2015
  • 639 Views

Comments

639 Views

CustomAttributes

Last updated 6 years ago

Comments

Common

(Enter the content of this article below)

Advanced

 
DotNetNuke has supported navigation providers since 2005. The provider model is based off of interfaces, promoting a one-size-fits-all mentality. This can be both a blessing and a curse. The curse as it relates to the navigation providers is that it limits the features that the navigation provider's control can support.

For example, if a menu wanted a mechanism to support horizontal submenus, the provider model would have to be changed which expose it to all providers, which of course makes little sense for something like a treeview With the released of DotNetNuke 4.5 the ability to specify custom attributes to the navigation providers was added. This can be accomplished by adding the following to the skin's ascx file.

The following directive needs to be added at the top

<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.UI.Skins" Assembly="DotNetNuke" %>


Then within your skin object you simply embed a CustomAttributes element, then specify one or more attributes.

<dnn:NAV ID="dnnNav" runat="server" ProviderName="DNNMenuNavigationProvider">
<CustomAttributes>
<dnn:CustomAttribute Name="SubMenuOrientation" Value="Horizontal"/>
</CustomAttributes>
</dnn:NAV>

How it works

This is accomplished by adding a Generics collection to the NavObjectBase (which is used by the Nav.ascx skin object).


<DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)> _
Public ReadOnly Property CustomAttributes() As Generic.List(Of CustomAttribute)
Get
Return m_objCustomAttributes
End Get
End Property

The provider will then be able to enumerate these custom attributes and apply them to the underlying control.

For Each objAttr As DotNetNuke.UI.Skins.CustomAttribute In Me.CustomAttributes
Select Case objAttr.Name.ToLower
Case "submenuorientation"
Me.Menu.SubMenuOrientation = DirectCast(System.Enum.Parse(Me.Menu.SubMenuOrientation.GetType, objAttr.Value), DotNetNuke.UI.WebControls.Orientation)

End Select
Next

Contents
No sections defined
Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out