Copied to clipboard

Flag this post as spam?

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


  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 08:40
    Niels Henriksen
    0

    Tutorial for adding content to tree?

    I am working on a webshop for at customer and I need to make my own tree (done and working) but my problem is when I'm clicking on the node in the tree I cant find out how to call the page. Are there a up-to-date tutorial for the Tree?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 03, 2017 @ 09:12
    Michaël Vanbrabandt
    0

    Hi Niels,

    can you give us some more details ( code or screenshots ) of what you have and want to achieve?

    You made your own tree you say, you mean a new section in the backoffice?

    Can you show us this how you have set up this section and tree?

    Thanks!

    /Michaël

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 09:22
    Niels Henriksen
    0

    Yes... I have made a section with nodes in the Tree. Each node has this code

    TreeNode node = CreateTreeNode("shopidee2", "shopid1", queryStrings, "Kategorierxx","icon-umb-content", false, string.Format("Shop/ShopTree/history/{0}", "1"));
    nodes.Add(node);
    

    The problem for me is to make it call the html (Shop/ShopTree/history/{0})

    I have it in:

    App_Plugins\Shop\backoffice\shopTree\history.html and history.controller.js

    Shop and shopTree is defined in top of ShopTreeController in Controllers

    [Tree("shop", "shopTree", "Shop for Umbraco")]
    [PluginController("Shop")]
    public class ShopTreeController : TreeController
    
  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 03, 2017 @ 09:24
    Michaël Vanbrabandt
    0

    Do you see the correct url in the bar when clicking on the node?

    What does the error console say?

    /Michaël

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 09:30
    Niels Henriksen
    0

    it says it cant find http://domain/umbraco/views/ShopTree/history.html

    And I have been looking in the code for https://github.com/ViGiLnT/ApproveIt to see if I could find any thing.... but no luck..

    I have added a picture to clarify what I want to do.

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 03, 2017 @ 09:34
    Michaël Vanbrabandt
    0

    Niels,

    can you show me the complete code of the GetTreeNodes method?

    Thanks

    /Michaël

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 09:37
    Niels Henriksen
    0
    protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            //var ctrl = new ShopApiController();
            var nodes = new TreeNodeCollection();
    
            //IUser user = UmbracoContext.Security.CurrentUser;
    
            //check if we're rendering the root node's children
            if (id == Constants.System.Root.ToInvariantString())
            {
                TreeNode node = CreateTreeNode("shopid1", "-1", queryStrings, "Kategorier", "icon-umb-content", true);
                nodes.Add(node);
    
                node = CreateTreeNode("shopid2", "-1", queryStrings, "Produkter", "icon-umb-content", true);
                nodes.Add(node);
    
                node = CreateTreeNode("shopid3", "-1", queryStrings, "Kunder", "icon-umb-content", true);
                nodes.Add(node);
    
            }
            else
            {
                // We're rendering the node properties
                int level = id.Count(c => c == '-');
    
                //if (level == 0)
                //{
                if (id == "shopid1")
                {
                    TreeNode node = CreateTreeNode("shopidee2", "shopid1", queryStrings, "Kategorierxx",
                        "icon-umb-content", false, string.Format("Shop/ShopTree/history/{0}", "1"));
                    nodes.Add(node);
    
                }
    
                if (id == "shopid2")
                {
                    TreeNode node = CreateTreeNode("shopidee2", "shopid2", queryStrings, "Produkterxx",
                        "icon-umb-content", false, string.Format("Shop/ShopTree/history/{0}", "1"));
                    nodes.Add(node);
    
                }
    
    
            }
    
            return nodes;
        }
    
  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 03, 2017 @ 09:39
    Michaël Vanbrabandt
    0

    Ok and now your plugin folder inside the App_Plugins folder, can you show me the content of it with all folders and files ( screenshot )

    /Michaël

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 09:44
    Niels Henriksen
    0

    In the Tree folder the filename is ShopTreeController.cs

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 03, 2017 @ 09:51
    Michaël Vanbrabandt
    0

    Niels,

    looks all good to me.

    The url when clicking on the node, is it like:

    umbraco/#/shop/shoptree/history/1
    

    /Michaël

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 10:00
    Niels Henriksen
    0
    umbraco/#/Shop/ShopTree/history/1
    
  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 03, 2017 @ 10:15
    Michaël Vanbrabandt
    0

    The only difference I can see with my code for custom sections is that I have a dash in front of my node tree urls:

    nodes.Add(this.CreateTreeNode("notes", id, queryStrings, "All notes", "icon-notepad", false, "/notely/notely/notes/0"));
    

    /Michaël

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 10:20
    Niels Henriksen
    0

    ok :( then it shows //Shop/ShopTree....

    I will try to go through the code again :)

    Thank you for your time

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Nov 03, 2017 @ 13:17
    David Brendel
    0

    Hi Niels,

    I always build my routes for tree nodes like this:

    queryStrings.GetValue<string>("application") +
    _treeAlias.EnsureStartsWith('/') + "/overviewCalendar/all"
    

    And then make sure that your folder structure uses the tree alias as folder name in this example.

    So in your example I would try to change ShopTree with shopTree as your folder is named shopTree.

    Regards David

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 13:22
    Niels Henriksen
    0

    where do you define _treeAlias?

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Nov 03, 2017 @ 14:11
    David Brendel
    0

    Hi Niels,

    the TreeController has a property for TreeAlias which you can use directly. In my example I wrapped the creation and therefore used a custom property.

    But normally you can just use this.TreeAlias in your custom tree.

    Regards David

  • Niels Henriksen 74 posts 277 karma points
    Nov 03, 2017 @ 14:20
    Niels Henriksen
    0

    whoooo.......

    the code

                       TreeNode node = CreateTreeNode("shopidee2", "shopid1", queryStrings, "Kategorierxx",
                        "icon-umb-content", false, queryStrings.GetValue<string>("application") + TreeAlias.EnsureStartsWith('/') + string.Format("/history/{0}", "1"));
                    nodes.Add(node);
    

    thats work :) Now I get anohter error but that was an expected error

Please Sign in or register to post replies

Write your reply to:

Draft