Custom section tree node route path takes from view folder
Hi all.
Using Umbraco 7.6.5
I am playing around with Custom Sections, and are stuck trying to set the route path.
if i set the route path to myCustomSection/settings/edit/1 it will try and take the edit.html from /View/settings/edit.html, how can i change it to take from /App_Plugins/MyPlugin/backoffice/settings/edit.html ?
Here is an exsampel.
// Let's say my tree alias is Parent.
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
if (id == "-1")
{
var rootNodes = new TreeNodeCollection();
// This one takes the view correct at /App_Plugins/MyPlugin/backoffice/parent/edit.html
var folder = CreateTreeNode("0", "-1", queryStrings, "Parent", "icon-truck color-blue", true);
rootNodes.Add(folder);
return rootNodes;
}
else
{
switch (id)
{
case "0":
var childNodes = new TreeNodeCollection();
// This one trying to get /View/settings/edit.html
var settings = CreateTreeNode("1", "0", queryStrings, "Settings", "icon-settings-alt color-blue", false, "myCustomSection/settings/edit/1");
childNodes.Add(settings);
// This one trying to get /View/child/edit.html
var anotherChild = CreateTreeNode("1", "0", queryStrings, "anotherChild", "icon-untitled color-blue", false, "myCustomSection/child/edit/1");
childNodes.Add(anotherChild);
return childNodes;
}
}
//this tree doesn't suport rendering any more levels
throw new NotSupportedException();
}
So what you are saying is that my route for settings should be myCustomSection/CustomTree/settings/1 and for the other child it should be myCustomSection/CustomTree/child/1.
What about delete and add? How would you then add those?
to get the id at the end you can access $routeParams.id in your angular controller for each element.
It doesn't really matter how deep your tree gets what you have to do is still point to the items in the root of the customtree folder. and pass in the ID of the item in the tree as the final parameter.
What i get from this is i could use the Edit/Add/Delete for one node type. Actually i think Edit is also used for Add.
But what about other node types in the same tree?
Let's say, i got 2 different node types.
First nodetype i use: (works)
Route = myCustomSection/Customtree/edit/1
View= /app_plugins/myCustomSection/backoffice/CustomTree/edit.html
// Menu
var menu = new MenuItemCollection();
// /app_plugins/myCustomSection/backoffice/CustomTree/edit.html
menu.Items.Add<CreateChildEntity, ActionNew>("Create new");
// /app_plugins/myCustomSection/backoffice/CustomTree/delete.html
menu.Items.Add<ActionDelete>("Delete");
return menu;
Second nodetype: (I dunno what to do)
// This part works.
Route = myCustomSection/Customtree/settings/1
View= /app_plugins/myCustomSection/backoffice/CustomTree/settings.html
// Menu (this part do no not work)
var menu = new MenuItemCollection();
// How do i tell it to take from settings.html?
menu.Items.Add<CreateChildEntity, ActionNew>("Create new");
// How do i tell it to take from settings_delete.html?
menu.Items.Add<ActionDelete>("Delete");
return menu;
My confusing point is how to set the settings nodetype Create and Delete route. i guess i need to make a settings_delete.html, but i dunno where i can tell it to take from that view and how to tell it to create from settings.html, when another nodetype already are using edit and delete.
Maybe i have to make my own IAction, but i can't get it to work.
public class SettingsCreateAction : IAction
{
public char Letter
{
get { return default(char); }
}
public bool ShowInNotifier
{
get { return false; }
}
public bool CanBePermissionAssigned
{
get { return false; }
}
public string Icon
{
get { return "icon-settings"; }
}
public string Alias
{
get { return "settings"; }
}
public string JsFunctionName
{
get { return ""; }
}
public string JsSource
{
get { return ""; }
}
}
As far as i know you can't do it with your own controllers :(
Umbraco will look for the tree/section alias, and if it doesn't exist everything goes back into the umbraco/views folder (which I would avoid putting anything into as you will get upgrade nightmares).
So you need to have everything in the same folder.
In the past i have just prefixed the filenames with the entity so for example :
it's not ideal - but i suppose the only other way to do it, is have a separate tree for each type which is good in terms of separation of code but this only works if the entities are not mixed in the structure of your tree.
Adding a section tree for each entity is ideal, in order to route properly. However, this is annoying because each TreeController will appear in the plugin tree.
Even I want to exist a single entity named A, I couldn't find a method to erase root nodes (which they correspond to each Tree Controllers defined).
Custom section tree node route path takes from view folder
Hi all.
Using Umbraco 7.6.5
I am playing around with Custom Sections, and are stuck trying to set the route path.
if i set the route path to myCustomSection/settings/edit/1 it will try and take the edit.html from /View/settings/edit.html, how can i change it to take from /App_Plugins/MyPlugin/backoffice/settings/edit.html ?
Here is an exsampel.
Any help is appreciated.
Hi
the routes have to match both the appAlias and tree alias to be found. if they don't then umbraco goes back into looking in the views folder.
so if for example you have a tree controller with
all your views will need to be in the form
and your views will need to match
Hi Kevin.
Thanks for answering.
So what you are saying is that my route for settings should be myCustomSection/CustomTree/settings/1 and for the other child it should be myCustomSection/CustomTree/child/1.
What about delete and add? How would you then add those?
HI
for children in the path they go on the end . with the action the thing after the tree.
so if we assume the node id of the child node is 1 then
would point to.
and
points to
similar for delete etc...
to get the id at the end you can access $routeParams.id in your angular controller for each element.
It doesn't really matter how deep your tree gets what you have to do is still point to the items in the root of the customtree folder. and pass in the ID of the item in the tree as the final parameter.
Hi
I am still confused, i hope you can bear with me.
What i get from this is i could use the Edit/Add/Delete for one node type. Actually i think Edit is also used for Add.
But what about other node types in the same tree?
Let's say, i got 2 different node types.
First nodetype i use: (works)
Second nodetype: (I dunno what to do)
My confusing point is how to set the settings nodetype Create and Delete route. i guess i need to make a settings_delete.html, but i dunno where i can tell it to take from that view and how to tell it to create from settings.html, when another nodetype already are using edit and delete.
Maybe i have to make my own IAction, but i can't get it to work.
I hope it make sense :)
Hi
you can create menu items with an alias and name :
so that would go to
you might need to set the icon and stuff this way, but you can access the menuitem properties, such as
icon
now - so you can do that.Thanks Kevin.
That got me going :)
So, from what I got, a section tree is used for CRUD operations for an entity. However, there is no way to:
It's bad, since I've spent around 3 days in figure it out that this is a limitation and can not pass.
I am not an expert in Umbraco, but can anyone tell me that I am wrong ?
Hi
As far as i know you can't do it with your own controllers :(
Umbraco will look for the tree/section alias, and if it doesn't exist everything goes back into the umbraco/views folder (which I would avoid putting anything into as you will get upgrade nightmares).
So you need to have everything in the same folder.
In the past i have just prefixed the filenames with the entity so for example :
and then the routes are like:
it's not ideal - but i suppose the only other way to do it, is have a separate tree for each type which is good in terms of separation of code but this only works if the entities are not mixed in the structure of your tree.
Adding a section tree for each entity is ideal, in order to route properly. However, this is annoying because each TreeController will appear in the plugin tree.
Even I want to exist a single entity named A, I couldn't find a method to erase root nodes (which they correspond to each Tree Controllers defined).
Do you know if is there such a capacity ?
Hi I think I made how writed in this post, but still get request from umbraco/views
My Controller
html
Where is wrong?
add
"/1"
to the end of your custom route like thisis working on a reply...