Share via


ConsoleNode Class

Represents the basic structure used for the Console menu.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Publishing.WebControls.ConsoleNode
    Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ModifyWebPartsNode
    Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ReportsNode

Namespace:  Microsoft.SharePoint.Publishing.WebControls
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class ConsoleNode
'Usage
Dim instance As ConsoleNode
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class ConsoleNode

Remarks

Each ConsoleNode object can optionally have child ConsoleNode objects and associated console ConsoleAction objects. Action user interfaces such as the Editing menu, Quick Access button, or Site Actions menu present various actions to the user. Each of these has an instance of the ConsoleDataSource object that provides a hierarchical collection of ConsoleNode objects. Some ConsoleNode objects implement the ConsoleAction class in a specific way.

When the Action property for a ConsoleNode is defined as a ConsoleAction, the properties of the ConsoleAction, such as DisplayText and href, are used as properties with the same names in the ConsoleNode.

When a property, such as ImageUrl, is defined in both a ConsoleNode object and a ConsoleAction object that the ConsoleNode references, the value specified in the ConsoleNode overrides the value in the referenced ConsoleAction if the corresponding Boolean value has been set. In this case, setting the UseActionImageUrl property to false causes the ConsoleNode to override the ConsoleAction property.

Each instance of this class represents an action or a submenu. For example, in the Site Actions menu, if a ConsoleNode has at least one child in the ChildConsoleNodes collection, it appears as the root of a submenu with the child ConsoleNodes appearing in the submenu. If the ConsoleNode has no child objects, it appears as a clickable action.

Examples

using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing.WebControls;
using Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions;

namespace Microsoft.SDK.SharePointServer.Samples.Publishing.SiteActionsMenuItem
{
    /// <summary>
    /// This sample adds an item to the Site Actions menu, when clicked goes to the Navigation Settings page.
    /// 
    /// The necessary steps to make this sample running:
    /// 1. Create a new C# class library project.
    /// 2. Add this snippet to the project.
    /// 3. Sign the assembly with a strong name.
    /// 4. Add references to the following assemblies:
    ///    a. System.Web
    ///    b. Microsoft.SharePoint
    ///    c. Microsoft.SharePoint.Publishing
    /// 5. Build the project.
    /// 6. Install the assembly to the server's Global Assembly Cache (GAC).
    /// 7. Replace the assembly information given in the following XML snippet with the assembly you have created.
    ///    (trick: An easy way to learn the Public Key Token of the assembly is
    ///            to right click the assembly in GAC and click properties.)
    /// 8. Copy the XML snippet below updated with the assembly information into CustomSiteActions.xml,
    ///    which is in Editing Menu folder in Master Page Gallery.
    ///    (trick: copying can be done as follows; navigate to Site Settings, then Master Page Gallery, and then Editing Menu folder.
    ///            Download a copy of CustomSiteActions.xml, update the local copy and upload back to the server. Finally publish the file.)
    /// 9. Do an iisreset on the server.
    /// 
    /// <references>
    ///     <reference TagPrefix="SharePointServerSamples" 
    ///       assembly="Microsoft.SDK.SharePointServer.Samples.Publishing.SiteActionsMenuItem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7aa57999e9b11a7c" 
    ///       namespace="Microsoft.SDK.SharePointServer.Samples.Publishing.SiteActionsMenuItem" />
    /// </references>
    /// <structure>
    ///  <ConsoleNode
    ///       Action="SharePointServerSamples:NavigationSettingsAction"  
    ///       MenuGroupId="300"  
    ///       Sequence="390"  
    ///       PermissionContext="CurrentSite"
    ///       HideStates="IsPublishingSiteFalse"
    ///       UIVersion="4"
    ///       ID="sampleNavSetng"/>
    /// </structure>
    /// 
    /// Explanation of the ConsoleNode properties;
    /// * Action is used to define the ConsoleAction that is used with this ConsoleNode.
    /// * MenuGroupId and Sequence define the position of the ConsoleNode inside the Site Actions menu.
    /// * PermissionContext defines the context (CurrentItem, CurrentList, CurrentSite, RootSite) to be used
    ///   while checking if the user has rights to use this ConsoleNode.
    /// * HideStates defines the AuthoringStates for which the ConsoleNode is hidden (not rendered on UI.)
    /// * UIVersion can be used to define a ConsoleNode specific to a UIVersion (v3 or v4).
    /// </summary>
    public class NavigationSettingsAction : ConsoleAction
    {
        /// <summary>
        /// This is the constructor of the specific ConsoleAction.
        /// </summary>
        public NavigationSettingsAction()
            : base()
        {
            this.DisplayText = "Navigation Settings";
            this.Description = "Change the navigation settings for this site";
        }

        /// <summary>
        /// Gets the AuthoringStates required to enable the menu item.
        /// </summary>
        public override AuthoringStates RequiredStates
        {
            get
            {
                return AuthoringStates.EmptyMask;
            }
        }

        /// <summary>
        /// Gets the SPBasePermissions required to use this Console Action.
        /// </summary>
        public override SPBasePermissions UserRights
        {
            get
            {
                return SPBasePermissions.AddAndCustomizePages;
            }
        }

        /// <summary>
        /// Gets the url that the browser navigates to, when the menu item is clicked.
        /// </summary>
        public override string href
        {
            get
            {
                string serverRelativeUrlOfCurrentWeb = SPContext.Current.Web.ServerRelativeUrl;
                string navigationSettingsRelativeUrl = "_layouts/AreaNavigationSettings.aspx";
                string result;

                if (serverRelativeUrlOfCurrentWeb.EndsWith("/"))
                {
                    result = serverRelativeUrlOfCurrentWeb + navigationSettingsRelativeUrl;
                }
                else
                {
                    result = serverRelativeUrlOfCurrentWeb + "/" + navigationSettingsRelativeUrl;
                }

                return result;
            }
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ConsoleNode Members

Microsoft.SharePoint.Publishing.WebControls Namespace