Copied to clipboard

Flag this post as spam?

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


  • Emil Tinebo 19 posts 39 karma points
    Jan 25, 2011 @ 21:18
    Emil Tinebo
    0

    Custom tree in custom section not working

    Hi,

    I'm sure this has been covered before but I cannot seem to find a solution for my problem.

    I have followed the tutorials over at Umbraco.TV regarding adding custom sections and trees and I got the section part right. However, the tree I want to create is not shown. Only the top node with no child nodes is displayed.

    Here is the code I am using to add a single test node to the tree:


    namespace BAS
    {
    public class loadBAS : BaseTree
    {
    public loadBAS(string application) : base(application) { }

    protected override void CreateRootNode(ref XmlTreeNode rootNode)
    {
    rootNode.Icon = FolderIcon;
    rootNode.OpenIcon = FolderIconOpen;
    rootNode.NodeType = TreeAlias;
    rootNode.NodeID = "init";
    }

    public override void RenderJS(ref System.Text.StringBuilder Javascript)
    {
    Javascript.Append(@"
    function openBAS(id)
    {
    parent.right.document.href = 'plugins\editBAS.aspx?id=' + id;
    }
    ");
    }

    public override void Render(ref XmlTree tree)
    {

    XmlTreeNode xNode = XmlTreeNode.Create(this);
    xNode.NodeID = "1";
    xNode.Text = "Custom node";
    xNode.Icon = "bas.gif";
    xNode.Action = "javascript:openBAS(1)";
    tree.Add(xNode);

    }
    }
    }

    And I added the following line to the umbracoAppTreeTable:

    False True 0 BAS BAS BAS legacy legacy BAS loadBAS NULL

     

    But it just won't work. Can someone please point me in the right direction?

    Thanks!

  • Rob Watkins 369 posts 701 karma points
    Feb 24, 2011 @ 19:15
    Rob Watkins
    0

    I'm getting this too; I copied the code exactly from a site I got it working on, and the new site is not showing anything but the top level node. I remember having difficulty with this but I can't remember what I did, annoyingly. Any pointers? 

    The treeHandlerType in the one that works has no namespace part, oddly. However it doesn't work either way in the new site - either with just the type name or a namespace qualified typename. How is the type loaded?

  • Rob Watkins 369 posts 701 karma points
    Feb 25, 2011 @ 15:49
    Rob Watkins
    0

    For some obscure reason when I went to work on this today it had started working. Web server not restarted. App was restarted but then it should have been when I copied the tree handler DLLs in anway, so no idea what got it working.

  • jwjanse 13 posts 33 karma points
    Feb 27, 2011 @ 14:37
    jwjanse
    0

    I am using Umbraco 4.6.1. Did you guys manage to translate the section labels? Instead of hardcoding the label titles in the code, I would like to get access the Umbraco dictionary. My current code tries to access dicitonary items in english) this way:

                var answered = XmlTreeNode.Create(this);
                answered.Text = umbraco.library.GetDictionaryItem("onlinequestion.answered"); 
                answered.Icon = "docPic.gif";
                answered.Action = "javascript:openViewAnsweredQuestions()";
    

    But all my section tree labels are empty.Some posts mention to use:

                conf.Text = new umbraco.cms.businesslogic.Dictionary.DictionaryItem("onlinequestion.configure").Value(0);
    

    but this results in compilation errors. Any ideas on how to do this? Or should I not go with dictionary items, but with a resource file or another way?

    Thanks,
    Jaco

  • Rob Watkins 369 posts 701 karma points
    Mar 02, 2011 @ 16:53
    Rob Watkins
    0

    Never used the dictionary, sorry!

  • Rob Watkins 369 posts 701 karma points
    Apr 20, 2012 @ 17:21
    Rob Watkins
    0

    Oh my God, now it's doing it on another site, and this time it hasn't fixed itself, anyone got any ideas?

  • Rob Watkins 369 posts 701 karma points
    Apr 20, 2012 @ 18:16
    Rob Watkins
    0

    Woo! I think I have it, by jingo! Either that, or it's working completely coincidentally.

    Did a bit of devling through the code, and found the class umbraco.cms.presentation.Trees.TreeDefinitionCollection which registers all of your app trees.

    This contains the code:

    //find the Application tree's who's combination of assembly name and tree type is equal to 
    //the Type that was found's full name.
    //Since a tree can exist in multiple applications we'll need to register them all.
    List<ApplicationTree> appTreesForType = appTrees.FindAll(
    delegate(ApplicationTree tree)
    {
            return (string.Format("{0}.{1}", tree.AssemblyName, tree.Type) == type.FullName);
    }
    );
    Which looked odd to me; you wouldn't create a fully qualified type / assembly name like that, and Type.FullName doesn't include the assembly anyway; this implies that in umbracoAppTree, what is stored in treeHandlerAssembly is actually the namespace of the type, and treeHandlertype is the simple type name.
    So, my tree type is MyProject.Umbraco.MyProjectTree, in assembly MyProject.
    What you need to put in umbracoAppTree is:
    treeHandlerAssembly = MyProject.Umbraco (namespace)
    treeHandlertype = MyProjectTree (simple type name)
    You don't need to put the assembly in anywhere.
    The reason I was getting odd results before was that my namespace and assembly names were identical on the site that worked; and I suspect that I was messing around with the namespace names in despair for the one that seemed to start workign suddenly.
    This now all works for me, but I haven't gone into the Umbraco core in massive depth, so if a dev could confirm this, that'd be cool :o)
  • nickornotto 403 posts 907 karma points
    Sep 28, 2012 @ 17:38
    nickornotto
    0

    I have the same problem.

    I have namespace MyProject.Umbraco and class ProApp within it. It is what I have put into umbracoAppTree table for treeHandlerAssembly and treeHandlerType respectively.

    I have added relevant data to umbracoApp and umbracoUser2app as well followinng tutorial on http://www.geckonewmedia.com/blog/2009/8/3/how-to-create-a-custom-section-in-umbraco-4

     

    And it's still not working for me.

    Not sure what else to do :(

  • nickornotto 403 posts 907 karma points
    Oct 01, 2012 @ 13:54
    nickornotto
    0

    Ok.

    I have managed to make it working based on this sample: http://www.nibble.be/?p=71

    Still not sure what was wrong with the other one though because looking at the code they look similar.

  • Comment author was deleted

    Feb 07, 2013 @ 17:39

    @Rob Watkins, Dude you helped me out thx!

Please Sign in or register to post replies

Write your reply to:

Draft