Search code examples
c#.netvisual-studioumbracoepiserver

Umbraco Page types programmatically(Just like in Episerver)


I just started out with Umbraco for my own projects because it is cheap in comparison to Episerver. Coming from the Episerver paradigm of strongly typed Page/block types and doing everything programmatically, i now find it hard to get into Umbraco in the way i hoped to.

I know how to create simple applications but i was hoping to define my Page Types like classes with properties that Umbraco then treats as Pages. My goal is to be able to create a hierarchy of page types where certain pages inherits properties from its parent page etc.

If I have a ArticleListingPage I want to inside of it's controller list all types of article pages. For example if I have a ArticleBasePage with the properties MainBody, Heading, Introduction then I want these to be inherited by ArticlePage and ArticleLongReadPage. Whenever I want to list these I want to search for pages of type <ArticleBasePage> and loop through the collection and render these. I don't like working in the UI I simply want to create a hierarchy of classes(that are pages) just like I would do in Episerver.

Is there any way to do this? Or a guide maybe? I don't like the approach of creating pages in the UI, I want my pages to be of a certain class so I can get the benefits that comes with that


Solution

  • Umbraco is vastly different from current Episerver versions (7+) in terms of managing the content model, but you can achieve somewhat similar code-first features to enable inheritance.

    You may want to have a look at uSiteBuilder (available as a NuGet package).

    Some more information available on Jon Jones' blog.