DotNetNuke Wiki


CustomAttributes

Modified on 2011/08/07 03:12 AM by cathal Categorized as Menu
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

Attend A Webinar
Start  Professional Edition Trial
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Sponsors

DotNetNuke Corporation

DotNetNuke (DNN) provides a suite of solutions that make designing, building and managing feature-rich sites and communities fast, easy and cost-effective. The DotNetNuke Platform CMS is the foundation for more than one million websites worldwide. DNN Social, our newest solution, enables businesses to create immersive, interactive communities. Thousands of organizations like True Value Hardware, Bose, Cornell University, Glacier Water, Dannon, Delphi, USAA, NASCAR, Northern Health and the City of Denver have leveraged DNN to deploy highly engaging business- critical websites. Our rapid growth in product sales and deployments resulted in DotNetNuke Corp. being named one of the fastest growing private companies in America by Inc. Magazine in 2011 and 2012.