public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "umbraco/backoffice/Plugins/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
public class StartUpHandlers : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
D. Back-end Controller - Returning view I want to see.
public class RewardsController : UmbracoAuthorizedController
{
public ActionResult Index()
{
return View("~/App_Plugins/Rewards/Views/RewardsHome/Index.cshtml");
}
}
So what am I missing?
I put break points in the RewardsTree Class but none of them are hit.
I also put break points on Application Started and those break points are being hit so I am pretty sure the route is being configured correctly.
Is there anything that I am missing? I have seen other examples using a TreeController insted of TreeBase which has confused me a bit.
are you using v7? If yes than that tutorial is pretty outdated. Have a look at TreeController which is now used for custom trees. Also there is no need for custom routes. And the backoffice in v7 is based un HTML views and angular. So don't think you can and should use mvc views in the Backend.
Yes I'm using V7 I did see a walk through with a Tree Controller as the focus, couldn't get it to quite work, but now I know this is the most up-to-date technique I will focus my efforts here.
As for the MVC views - From everything I have read you can customise the UI using three options, MVC, Webforms or Agular & WebApi.
I have gone for MVC becuase that is my strongest skill set, if anyone else could clarify these approaches and how/if they apply to the latest v7 of Umbraco - that would be very helpful.
I have managed to get a custom tree displaying in a custom section! At last! -
The problem I had was two fold.
From all the tutorials online that walk you through how to do this when defining the custom tree some tutorials inherit from BaseTree and others inherit from TreeController -
I have got it to work inheriting from TreeController, from what I understand using the BaseTree is the 'old way' of doing it.
I'm running Umbraco version 7.6.4 assembly: 1.0.6396.36621 - I'm not sure if the old way works using this version or not, but I couldn't get it to work.
I got my project to compile and run, the custom section showed up, but the custom tree didn't, when I clicked the custom section an error was thrown.
System.NullReferenceException: Object reference not set to an instance of an object.
Part of stack trace looks like this:
Umbraco.Web.Trees.ApplicationTreeExtensions.TryLoadFromControllerTree(ApplicationTree appTree, String id, FormDataCollection formCollection, HttpControllerContext controllerContext)
at Umbraco.Web.Trees.ApplicationTreeController.
It wasn't obvious why this was happening, but after a bit of reasearch I worked out this was becuase....................
I am using a IoC contanier and for this to work I needed to make sure the TreeController is registered in the containier! - This is something that is not mentioned in any documentation or tutorials relating to creating custom trees. The documentation assumes your using Umbraco with out an IoC container.
In my case I'm using Autofac so all I had to do was add this to my container registration code:
Hi Ayo,
I don't know how you made it working because in the Kevin Giszewski's example he inherits from FileSystemTreeController not like in Tim's example from TreeController unless this is what you needed.
I still have trouble to display even the section tree even though I followed both examples very carefully.
Custom Sections & Custom Trees MVC approach.
Hi guys,
I have spent hours and hours trying to get a custom tree to show up in a custom section in umbraco. - With out success.
So far I have managed to create a new section, but when I click that section nothing happens.
What should happen is a custom tree should be displayed with one node. When you click that node It should display an MVC view.
This is what I have done so far, it is based around this tutorial.
http://www.jondjones.com/learn-umbraco-cms/umbraco-developers-guide/customising-umbraco-ui/how-to-display-an-mvc-view-in-the-umbraco-backend
A. Create the section
B. Create the Tree
C. RegisterRoutes (called on ApplicationStarted)
D. Back-end Controller - Returning view I want to see.
So what am I missing?
I put break points in the RewardsTree Class but none of them are hit.
I also put break points on Application Started and those break points are being hit so I am pretty sure the route is being configured correctly.
Is there anything that I am missing? I have seen other examples using a TreeController insted of TreeBase which has confused me a bit.
ANY ideas? - very stuck
Hi Ayo,
are you using v7? If yes than that tutorial is pretty outdated. Have a look at TreeController which is now used for custom trees. Also there is no need for custom routes. And the backoffice in v7 is based un HTML views and angular. So don't think you can and should use mvc views in the Backend.
Regards David
Yes I'm using V7 I did see a walk through with a Tree Controller as the focus, couldn't get it to quite work, but now I know this is the most up-to-date technique I will focus my efforts here.
As for the MVC views - From everything I have read you can customise the UI using three options, MVC, Webforms or Agular & WebApi.
I have gone for MVC becuase that is my strongest skill set, if anyone else could clarify these approaches and how/if they apply to the latest v7 of Umbraco - that would be very helpful.
Thanks for your response David.
Hi Ayo,
maybe have a look here: https://our.umbraco.org/forum/developers/extending-umbraco/46514-Can-you-use-NET-MVC-in-Umbraco-7-Backoffice
Thats the biggest thread I know in regards to that topic.
But I strongly suggest going with angular as the BaseTree stuff will be removed with v8 I think. Of course that version is not that near but anyway.
Sadly I have currently no complete tutorial for the angular way at hand.
Regards David
I have managed to get a custom tree displaying in a custom section! At last! -
The problem I had was two fold.
From all the tutorials online that walk you through how to do this when defining the custom tree some tutorials inherit from BaseTree and others inherit from TreeController -
I have got it to work inheriting from TreeController, from what I understand using the BaseTree is the 'old way' of doing it.
I'm running Umbraco version 7.6.4 assembly: 1.0.6396.36621 - I'm not sure if the old way works using this version or not, but I couldn't get it to work.
So after following the guide lines in chapter 16 (Custom Sections, Trees and Actions) of this book: https://github.com/kgiszewski/LearnUmbraco7
I got my project to compile and run, the custom section showed up, but the custom tree didn't, when I clicked the custom section an error was thrown.
System.NullReferenceException: Object reference not set to an instance of an object.
Part of stack trace looks like this:
Umbraco.Web.Trees.ApplicationTreeExtensions.TryLoadFromControllerTree(ApplicationTree appTree, String id, FormDataCollection formCollection, HttpControllerContext controllerContext) at Umbraco.Web.Trees.ApplicationTreeController.
It wasn't obvious why this was happening, but after a bit of reasearch I worked out this was becuase....................
I am using a IoC contanier and for this to work I needed to make sure the TreeController is registered in the containier! - This is something that is not mentioned in any documentation or tutorials relating to creating custom trees. The documentation assumes your using Umbraco with out an IoC container.
In my case I'm using Autofac so all I had to do was add this to my container registration code:
and suddenly everything works!
Really hope this helps someone else.
Umbraco (7.6. 4) / Autofac.Mvc5 (4.0.2) / Autofac.WebApi2 (4.0.1) / << That's the combination of nuget packages that are working for me.
Hi Ayo, I don't know how you made it working because in the Kevin Giszewski's example he inherits from FileSystemTreeController not like in Tim's example from TreeController unless this is what you needed.
I still have trouble to display even the section tree even though I followed both examples very carefully.
The section is displaying just with not tree in it and the controller doesn't hit at all on debugging. I described my issue here: https://our.umbraco.com/forum/extending-umbraco-and-using-the-api//98104-trouble-disaplying-custom-section-in-umbraco-76
is working on a reply...