简体   繁体   English

Umbraco页的编程方式(就像Episerver中一样)

[英]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. 我刚开始使用Umbraco进行自己的项目,因为与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. 来自强类型页面/块类型的Episerver范例,并且以编程方式进行所有操作,我现在发现很难以我希望的方式进入Umbraco。

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. 我知道如何创建简单的应用程序,但是我希望定义自己的页面类型,例如具有Umbraco随后将其视为页面的属性的类。 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. 如果我有ArticleListingPage我想在它的控制器列表中列出所有类型的文章页面。 For example if I have a ArticleBasePage with the properties MainBody , Heading , Introduction then I want these to be inherited by ArticlePage and ArticleLongReadPage . 例如,如果我有一个ArticleBasePage与性能MainBodyHeadingIntroduction那么我想这些被继承ArticlePageArticleLongReadPage Whenever I want to list these I want to search for pages of type <ArticleBasePage> and loop through the collection and render these. 每当我要列出这些页面时,我都想搜索<ArticleBasePage>类型的页面,并遍历集合并呈现这些页面。 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. 我不喜欢在UI中工作,我只想像在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 我不喜欢在UI中创建页面的方法,我希望页面属于某个类,这样我才能获得随之而来的好处

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. 在管理内容模型方面,Umbraco与当前的Episerver版本(7+)有很大不同,但是您可以实现一些类似的代码优先功能来启用继承。

You may want to have a look at uSiteBuilder (available as a NuGet package). 您可能想看看uSiteBuilder (以NuGet包的形式提供)。

Some more information available on Jon Jones' blog . 有关更多信息,请访问Jon Jones的博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM