Copied to clipboard

Flag this post as spam?

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


  • mannaky 12 posts 60 karma points
    Sep 11, 2014 @ 14:16
    mannaky
    0

    Custom url for TreeNode click [v 7.1.6]

    Hello,

    I have created my own app Tree in the Umbraco backend. However, I don't manage to get to a custom url when clicking on the TreeNode element.

        [PluginController("mySection")]
        [Tree("mySection", "mySectionTree", "My section", iconClosed: "icon-doc")]
    public class CustomSectionTreeController : TreeController { protected override TreeNodeCollection GetTreeNodes(string id, System.Net.Http.Formatting.FormDataCollection queryStrings) { var item = this.CreateTreeNode("myNode", id, queryStrings, "My node", "icon-truck", false); nodes.Add(item); return nodes; }

    The custom url points me always to /App_Plugins/mySection/backoffice/mySectionTree/edit.html. How can I achive a redirection to a custom url?

    Thanks in advance,

    mannyk

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Sep 11, 2014 @ 16:58
    David Brendel
    0

    Hi,

    there is an additional parameter for the CreateTreeNode-Method which you can use to set the path to your file.

    So after the boolean property, just add another one with the path.

    Hope that helps.

    David

  • mannaky 12 posts 60 karma points
    Sep 12, 2014 @ 10:04
    mannaky
    0

    Hello,

    yes, I know that parameter, but I was not able to go to a different url by using it.

    Let's say I want to navigate to /umbraco/myfolder/mypage.aspx.

    If I am using this as my route path umbraco tries to route me to views/umbraco/myfolder/mypage.aspx.html.

    Can you or someone else tell me how to properly use this route path?

    Thank you very much,

    mannyk

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Sep 15, 2014 @ 09:21
    David Brendel
    0

    You can't use aspx pages while doing that.

    Umbraco reqiures just plain html files for your views, thats why he automatically adds the .html to the end.

    Thats becauso the views in v7 are just plain html files with angularjs for the functionality and umbracp api calls to save and load data in

    Maybe take a look here: http://umbraco.github.io/Belle/#/tutorials.

    There are some tutorials on how to wire everything together.

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Sep 16, 2014 @ 21:20
    Marcel van Helmont
    1

    You can do this.. so you get a url like http://localhost/umbraco/#/mySection/mySectionTree/editCategorie/1010

    [PluginController("mySection")]
    [Tree("mySection", "mySectionTree", "My section", iconClosed: "icon-doc")]
    public class CustomSectionTreeController :  TreeController
    {
        protected override TreeNodeCollection GetTreeNodes(string id, System.Net.Http.Formatting.FormDataCollection queryStrings)
        {
            var item = this.CreateTreeNode("myNode", id, queryStrings, "My node", "icon-truck", false, FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + StringExtensions.EnsureStartsWith(this.TreeAlias, '/') + "/editCategorie/" + id));
            nodes.Add(item);
    
            return nodes;
        }
    
  • Sabin Regmi 13 posts 93 karma points
    Apr 04, 2016 @ 06:46
    Sabin Regmi
    0

    Hi Marcel,

    Thank you very much. I searched lots of sites for this solution and finally I find your solution. Its amazing....

    Thanks again.

    Regards:

    Sabin

  • mannaky 12 posts 60 karma points
    Sep 18, 2014 @ 10:37
    mannaky
    0

    Hello,

    thank you very much! I I was now able to route to a custom html file that later will redirect me to the specified aspx page.

    Regards,

    mannyk

  • Zakhar 171 posts 397 karma points
    Apr 01, 2016 @ 15:51
    Zakhar
    0

    Ok, I know it's an old topic, but I'm having the same problem and can't route to my custom html file.

    What's the folder structure should be in App_Plugins folder?

    I get a 404 error and it looks like Umbraco is looking for my path in umbraco\views folder

    Request error: The URL returned a 404 (not found): 
    views/AdminNewSectionTree/hostingReports.html
    
  • Manish Agrawal 25 posts 218 karma points
    Aug 09, 2017 @ 05:31
    Manish Agrawal
    0

    Hi,

    I am facing the same issue. I want to get html from plugin folder but the system is finding the html in default umbraco view folder. How can I change the path of the file. I have set the route as showing in "Marcel Van" comment. It works when we add file in umbraco/view folder but I want to change the file path.

    Please suggest.

    Thanks

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 09, 2017 @ 07:17
    David Brendel
    0

    Hi Manish,

    normally you would use FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + _treeAlias.EnsureStartsWith('/') + "/viewName/" + someId.ToString()

    With that it would try to resolve the view under App_Plugins/ApplicationFolder/backOffice/treeAlias/viewName.html

    Regards David

  • Ayo Adesina 430 posts 1023 karma points
    Aug 31, 2017 @ 14:07
    Ayo Adesina
    0

    App_Plugins/ApplicationFolder/backOffice/treeAlias/viewName.html

    What if you wanted to add 'SomeFolder' so you can organise the views, do you know how I could do that?

    so.. like this.. App_Plugins/ApplicationFolder/backOffice/treeAlias/someFolder/viewName.html

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 31, 2017 @ 14:13
    David Brendel
    0

    Hi Ayo,

    it should just work when adding the folder to the route. Umbraco uses the route as path on file system.

    Have you tried it?

    Regards David

  • Ayo Adesina 430 posts 1023 karma points
    Aug 31, 2017 @ 14:28
    Ayo Adesina
    0

    trying it now, i'll update this shortly. Thanks.

  • Ayo Adesina 430 posts 1023 karma points
    Aug 31, 2017 @ 16:10
    Ayo Adesina
    0

    Hi David,

    Its been a bit fustrating...

    This works

    FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + "/rewardsTree/editopco/" + opco.Id.ToString();
    

    The name of my view is editopco.html

    This means that my all my views have to be here: App_Plugins/Rewards/backoffice/rewardsTree/editopco.html

    But I want to put my organise my views like this (all views to do with 'opco' to be in one folder) App_Plugins/Rewards/backoffice/rewardsTree/views/opco/edit.html

    So I try to get to that view like this:

    FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + "/rewardsTree/views/opco/edit/" + opco.Id.ToString();
    

    Which genrates this HTML

    <a href="#/rewards/rewardsTree/views/opco/edit/1" ng-click="select(node, $event)">NameHere</a>
    

    Which seems right to me... but when you click it, Umbraco redirects me to the content section of the Umbaco UI.......

    Been stuck on this for a while now, might have to just put all the views in the same folder.

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 31, 2017 @ 19:21
    David Brendel
    0

    Hi Ayo,

    ok, then the only other way to separate is to have multiple trees in your section as then each tree would at least have its own folder which you can use to separate your views.

    Regards David

  • Manish Agrawal 25 posts 218 karma points
    Aug 09, 2017 @ 08:52
    Manish Agrawal
    0

    Hi David,

    Thanks for your reply.

    I am getting following message when I am trying to get page from App_plugin folder.

    nodes.Add(CreateTreeNode(leftLink.Id + "", id, queryStrings, leftLink.Name, "icon-bird", false, FormDataCollectionExtensions.GetValue

    enter image description here

    I want to create browser url like this "http://localhost:49828/umbraco#/createjob"

    this url should access the page in App_Plugin folder.

    Thanks

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 09, 2017 @ 09:27
    David Brendel
    0

    Hi Manish,

    the "backOffice" part will be added automatically. You don't need to add it.

    So as in my example you concatenate the application alias, the tree alias, the view name without the extension and then the id of the item to edit. If you want to use an overview page you still have to add something as the "id". I just use "all" for that.

    Regards David

  • Manish Agrawal 25 posts 218 karma points
    Aug 09, 2017 @ 10:36
    Manish Agrawal
    0

    Hi David,

    I am passing url like this and getting url in browser like this : http://localhost:49828/umbraco#/myapp/jobs/addjob

    enter image description here

    Do I need to set route url also to map with App_plugins file. I am still getting same error.

    Please suggest.

    Regards Manish

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 09, 2017 @ 10:46
    David Brendel
    0

    Hi Manish,

    as said it only works when you add something like an id at the end. So try to add "/new" or something to your url.

    Also, check if your application outcome is the same as the folder that your files are in and check if the tree alias is also set to jobs. Could also be case sensitive. So control the spelling.

    Regards David

  • Manish Agrawal 25 posts 218 karma points
    Aug 09, 2017 @ 11:34
    Manish Agrawal
    0

    Thanks David,

    It works with Id param.

    can we customize the route.js if I want to remove id from url for App_plugins files.

    Regards Manish

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 09, 2017 @ 13:40
    David Brendel
    0

    Hi Manish,

    not sure if something like a route.js exists but if it's umbraco internals then I wouldn't recommend to change it.

    Normally something like this is done by having a menu item like "Create Job" and some kind of "Jobs" node. So it depends on what you try to achieve.

    Regards David

Please Sign in or register to post replies

Write your reply to:

Draft