Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Maton 387 posts 660 karma points
    Jul 30, 2012 @ 15:21
    Tom Maton
    0

    Create custom tree and create Umbraco nodes under the tree not in custom database table

    Hi All,

    I've now got to the point now that after 3-4 days of dev, investigation, watching the umbraco videos, googling etc I cant seem to find anyway of creating Umbraco nodes under my tree in my own section. So they are saved in the umbracoContentXml table and not in my own (just like uWebshop does)

    I've followed the videos and updated the UI.xml to use the content.ascx

    I keep getting the following error in my modal window when I right click and click create

    This is my current code:

    using System;
    using System.Collections.Generic;
    using umbraco.cms.businesslogic.web;
    using umbraco.cms.presentation.Trees;
    using umbraco.BusinessLogic.Actions;
    using umbraco.interfaces;
    namespace ContractorSite.CustomTrees
    {
        public class EmailTemplateTree : BaseContentTree
        {
            private Document[] emailTemplates;
            public EmailTemplateTree(string application)
                : base(application)
            {
                emailTemplates = Document.GetChildrenForTree(m_id);
            }
            protected override void CreateRootNode(ref XmlTreeNode rootNode)
            {
                rootNode.Text = "Email Template";
                rootNode.Icon = ".sprTreeFolder";
                rootNode.OpenIcon = ".sprTreeFolder_o";
                rootNode.NodeID = "emailTemplate2";
                rootNode.NodeType = this.TreeAlias;
            }
            
            protected override void CreateRootNodeActions(ref List<IAction> actions)
            {
                actions.Clear();
                actions.Add(ActionNew.Instance);
                actions.Add(ActionRefresh.Instance);
            }
            public override void Render(ref XmlTree tree)
            {
                foreach (Document emailTemplate in emailTemplates)
                {
                    var dNode = XmlTreeNode.Create(this);
                    dNode.NodeID = emailTemplate.Id.ToString();
                    dNode.Text = emailTemplate.Text;
                    dNode.Icon = "banner_design.png";
                    dNode.Action = "javascript:openContent(" + emailTemplate.Id + ")";
                    dNode.OpenIcon = "banner_design.png";
                    dNode.Icon = "banner_design.png";
                    tree.Add(dNode);
                }
            }
            public override void RenderJS(ref System.Text.StringBuilder javascript)
            {
                javascript.Append(
                    @"
                        function openContent(id)
                        {
                            parent.right.document.location.href = editContent.aspx?id=' + id
                        }
                    ");
            }
        }
    }

    This is driving me nuts, I cant seem to get any further than this window and so any help would be greatly appreciated.

    Thanks,

    Tom

Please Sign in or register to post replies

Write your reply to:

Draft