I developing my first backend extension for Umbraco. I'm struggle already with TreeController. I have three level deep tree structure. But I can't make the routing work. Umbraco looks in the views folder...
Error message: Request error:
The URL returned a 404 (not found): views/raceseries/edit.html
Tree navigation:
Race Series 1 (/mayhem/raceseries/edit/Race+Series+1)
2015 (/mayhem/raceyear/edit/2015)
Race 1 (/mayhem/race/edit/1)
Folder structure:
App_Plugins
Mayhem
BackOffice
RaceSeries
edit.html
RaceYear
edit.html
Race
edit.html
TreeController:
[PluginController("Mayhem")]
[Tree("mayhem", "Mayhem", "Races", "icon-message", "icon-message", true, 5)]
public class MayhemTreeController : TreeController
{
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
var nodes = new TreeNodeCollection();
if (id == Constants.System.Root.ToString())
{
var node1 = CreateTreeNode(WebUtility.UrlEncode("Race Series 1"), null, queryStrings, "Race Series 1", "icon-tags", true);
node1.RoutePath = "/mayhem/raceseries/edit/" + WebUtility.UrlEncode("Race Series 1");
nodes.Add(node1);
var node2 = CreateTreeNode(WebUtility.UrlEncode("Race Series 2"), null, queryStrings, "Race Series 2", "icon-tags", true);
node2.RoutePath = "/mayhem/raceseries/edit/" + WebUtility.UrlEncode("Race Series 2");
nodes.Add(node2);
}
else
{
// get years from race series
if (!id.IsNumbic())
{
int[] years = {2014, 2015};
foreach (var item in years)
{
var node = CreateTreeNode(item.ToString(), id, queryStrings, item.ToString(), "icon-message", true);
node.RoutePath = "/mayhem/raceyear/edit/" + item;
nodes.Add(node);
}
}
else // get all races
{
var raceNode1 = CreateTreeNode("123", id, queryStrings, "06-28 Race 2", "icon-message", false);
raceNode1.RoutePath = "/mayhem/race/edit/123";
nodes.Add(raceNode1);
var raceNode2 = CreateTreeNode("124", id, queryStrings, "05-06 Race 1", "icon-message", false);
raceNode2.RoutePath = "/mayhem/race/edit/124";
nodes.Add(raceNode2);
}
}
return nodes;
}
Our help would be greatly appreciated, Thanks Stefan
i think the routing to the views also include the Name of youre tree. So you have to add a folder named "mayhem" to the backoffice folder and move your currently folder to the "mayhem" folder.
customize routing in section tree controller
Hi,
I developing my first backend extension for Umbraco. I'm struggle already with TreeController. I have three level deep tree structure. But I can't make the routing work. Umbraco looks in the views folder...
Tree navigation:
Folder structure:
TreeController:
Our help would be greatly appreciated, Thanks Stefan
Hi stevo,
i think the routing to the views also include the Name of youre tree. So you have to add a folder named "mayhem" to the backoffice folder and move your currently folder to the "mayhem" folder.
Regards David
Hi Dave!
Thanks for your answer! I tried it. It didn't work. But I found the answer here.
I had to changed my folder structure.
TreeController
Important is the second parameter by the Tree declaration:
That is the tree name in the url (case sensitive!! )
[Tree("mayhem", "race", "Races", "icon-message", "icon-message", true, 5)]
nodeToAdd.RoutePath = "/mayhem/race/series/" + WebUtility.UrlEncode(series.Key);
Folder structure:
It's not perfect but I works. Cheers, Stefan
Any idea how to add an additional querystring to the url? I tried to do it manually and the "?" ended up url encoded
Hi Taylor.
Think you have to add them as "/param" to work.
Regards David
is working on a reply...