Copied to clipboard

Flag this post as spam?

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


  • Stuey 3 posts 73 karma points
    Apr 07, 2017 @ 09:44
    Stuey
    0

    tree controller custom routing to a different package

    I need some help with routing,

    I am looking for a way (if it is possible) to link to a view within a separate package.

    I have a custom section called 'jaywingLabs' and inside that section I have a tree called 'jaywingPackages'. I would like for every node inside that tree to point towards its own custom view outside of the current package.

    for instance: 'JaywingAnalyticsHelper'

    So far I have followed the other threads on this forum to link to a custom view but that exists within the current package. When I change the package name in the route Umbraco just redirects me to the content page.

    Folder structure:

    • App_Plugins
      • JaywingLabs
        • backoffice
          • jaywingPackages view.html
      • JaywingAnalyticsHelper
        • backoffice
          • jaywingPackages view.html

    TreeController:

    [Tree("jaywingLabs", "jaywingPackages", "Jaywing Packages")]
            [PluginController("JaywingLabs")]
            public class JaywingLabsTreeController : TreeController
            {
                protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
                {
                    return new MenuItemCollection();
                }
    
                protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
                {
                    //check if we're rendering the root node's children
                    if (id == Constants.System.Root.ToInvariantString())
                    {
                        var nodes = new TreeNodeCollection();
    
                        var repo = new JaywingLabsPackageRepository();
    
                        foreach (InstalledPackageModel pack in repo.getJawingPackages())
                        {
                            var alias = pack.Name.Replace(" ", String.Empty);
                            //var route = string.Format("{0}/jaywingPackages/view/0", alias);
                            var route = "jaywingLabs/jaywingPackages/view/0";
                            var node = CreateTreeNode(pack.Id.ToString(), id, queryStrings, pack.Name, "icon-pushpin", false, route);
                            nodes.Add(node);
                        }
    
                        return nodes;
                    }
    
                    //this tree doesn't suport rendering more than 1 level
                    throw new NotSupportedException();
    
                }
            }
    

    Is what I am trying to do possible without redirecting or using angular's ngInclude. Help would be greatly appreciated.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

    Continue discussion

Please Sign in or register to post replies