Umbraco: Create Custom Content node In Umbraco by c#.

In Umbraco we come across situation to create some content node by programatically.

 First Reference Dll:  umbraco.BusinessLogic;  umbraco.presentation; umbraco.uicontrols;


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

using umbraco.BusinessLogic;
using umbraco.presentation.masterpages;
using umbraco.uicontrols;

namespace EventSamples
{
    public class TreeEvent : ApplicationBase
    {
        public TreeEvent()
        {
            umbraco.cms.presentation.Trees.BaseTree.BeforeNodeRender += new     umbraco.cms.presentation.Trees.BaseTree.BeforeNodeRenderEventHandler(BaseTree_BeforeNodeRender);
        }

        void BaseTree_BeforeNodeRender(ref umbraco.cms.presentation.Trees.XmlTree sender, ref umbraco.cms.presentation.Trees.XmlTreeNode node, EventArgs e)
        {
            if (node.NodeType == "content" &&  node.Menu != null)
            {
                node.Menu.Insert(0, new ContentProperty());
                node.Menu.Insert(1, umbraco.BusinessLogic.Actions.ContextMenuSeperator.Instance);
            }
        }
    }

    public class ContentProperty : umbraco.interfaces.IAction
    {
        #region IAction Members
        private string _alias = "Content Test";
        public string Alias
        {
            get { return _alias; }
        }

        public bool CanBePermissionAssigned
        {
            get { return true; }
        }

        public string Icon
        {
            get { return "tree/hjerte.gif"; }
        }

        public string JsFunctionName
        {
            get
            {
                return "alert('Hi I am here');";
            }
        }

        public string JsSource
        {
            get { return ""; }
        }

        public char Letter
        {
            get { return '¨'; }
        }

        public bool ShowInNotifier
        {
            get { return false; }
        }

        #endregion
    }
}

In Above code I am creating node by register event handler.You can also use another method to create custom node in umbraco.

After running above code placed dll in bin folder and open again umbraco you will able to see Content Test node.

Another Umbraco Article

Page Keyword: Custom node creation in umbraco by c#, How to create node in umbraco, Create Content node by c#.

Advertisements

3 thoughts on “Umbraco: Create Custom Content node In Umbraco by c#.

  1. Pingback: Umbraco: How to Create Custom data type in umbraco using c#. | [Code Destination]

  2. Pingback: Create your first Rss Feed Burner in umbraco | [Code Destination]

  3. Pingback: Install umbraco manually. | [Code Destination]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s