Copied to clipboard

Flag this post as spam?

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


  • David 28 posts 156 karma points
    Mar 21, 2017 @ 16:16
    David
    0

    Custom Tree Controller - Declaring other edit.html

    Hello my friends,

    I am using Umbraco version 7.5.3.

    I've got a Custom Section with custom tree within. In this tree you can create new "form" nodes.

    Forms (With create function)

    1. form1
    2. form2

    That works well. Now I need to extend this tree with an other parent-node called "News" like that:

    Forms (With create function)

    1. form1
    2. form2

    News (With create function)

    1. news1
    2. news2

    In my tree controller I've got the following code for adding a node:

       if (id == "news")
            {
                menu.Items.Add<CreateChildEntity, ActionNew>(textService.Localize(ActionNew.Instance.Alias));
                menu.Items.Add<RefreshNode, ActionRefresh>(textService.Localize(ActionRefresh.Instance.Alias), true);
            }
    
            if (id == "forms")
            {
                menu.Items.Add<CreateChildEntity, ActionNew>(textService.Localize(ActionNew.Instance.Alias));
                menu.Items.Add<RefreshNode, ActionRefresh>(textService.Localize(ActionRefresh.Instance.Alias), true);
            }
    

    My problem right now is, that if I click on Create in Umbraco on a "NewsItem" it redirects me always to the edit.html of my forms.

    Is there a way to determine the path to my edit.html of my news?

    My current projectstructure looks like that

    App_Plugins -> Projectname -> BackOffice -> CustomTree -> here ist my edit.html

    I would like to have 2 Folders instead like that.

    1. Forms -> edit.html
    2. News -> edit.html

    What i tried:

    I changed the alias of the added item to = "News/Edit", but it opened it as a dialog(like the common delete window in umbraco) and not as a the common create window of umbraco. I tried to make a second treecontroller but my backend file structure changed and it didnt looked that good.

    Forms->Forms-> Form1, Form2

    News -> News-> Form1,Form2

    Conclusion.

    I want a custom tree in my custom section with 2 parent nodes where it should be able to create different child item (news and forms). Does anyone has a solution?

    Thank you for you time and thank you in advance. :)

    Mfg David

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Mar 23, 2017 @ 07:33
    David Brendel
    1

    Hi David,

    you can change the route which is used for menu items:

    var menuItem = new umbWeb.Models.Trees.MenuItem("createCalendar",
            _textService.Localize("EventCalendar/tree_createCalendar",
             CultureInfo.CurrentCulture)) { Icon = "add" };
    menuItem.NavigateToRoute(FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + StringExtensions.EnsureStartsWith(treeAlias, '/') + "/editCalendar/0?create=true");
    

    With this you should be able to set the path to your edit file. In My example the editCalendar.html is used.

    Regards David

Please Sign in or register to post replies

Write your reply to:

Draft