Copied to clipboard

Flag this post as spam?

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


  • John 4 posts 54 karma points
    Aug 29, 2021 @ 05:44
    John
    0

    Plugin - TreeNode is not loading views from folders

    HI folks,

    I would like your help please. I'm learning to work with TreeNodes and Views. I followed a tutorial at https://our.umbraco.com/documentation/Extending/Section-Trees/trees

    Problem

    The problem is my plugin is set up with links to views in a subfolder, but it does not load those views and the last part of the URL is chopped off. Why is this happening?

    Overview

    I've created a generic plugin. The plugin name is generalPlugin, the tree alias name is generalPluginAlias and the treegroup name is generalPluginGroup.

    enter image description here

    It has a TreeController set up with nodes to point at generic webpages. Some pages at root level of plugin and some in a subfolder.

    enter image description here

    This is my code which creates TreeNodes with route paths.

    enter image description here

    This is how it's rendered on screen. I can click on Tea-Edit and it will load the view from the route path "generalPlugin/generalPluginAlias/tea-edit"

    enter image description here

    However if I try to load a view from "generalPlugin/generalPluginAlias/cats/edit" or "generalPlugin/generalPluginAlias/cats/edit?id=0" by clicking on the link cats or cats with id, the last part of the URL is cut off and Umbraco website throws an error, saying page cannot be found at "/App_Plugins/GeneralPlugin/backoffice/generalPluginAlias/cats.html".

    If you look at the screenshot below, you can see my link in the status pointing at "https://localhost:4432/umbraco/#/generalPluginAlias/cats/edit?id=0" but my Umbraco website is trying to load it from "/App_Plugins/GeneralPlugin/backoffice/generalPluginAlias/cats.html".

    Why was my URL cropped?

    enter image description here

  • John 4 posts 54 karma points
    Sep 14, 2021 @ 07:40
    John
    100

    I was unable to find a way to load views from sub-directories in my plugin folder.

    Instead, I've put all files into one folder at top level and added a category name and action suffix to each filename e.g. dogs-view.html, dogs-edit.html. That works for me.

    enter image description here

    Out of interest, another developer had the same problem and posted his answers similiar as above.

    https://our.umbraco.com/forum/developing-packages/87713-custom-section-tree-node-route-path-takes-from-view-folder

Please Sign in or register to post replies

Write your reply to:

Draft