简体   繁体   English

Asp.net Mvc:创建一个简单的cms

[英]Asp.net Mvc: Creating a simple cms

I am trying to build my own CMS for myself and my clients. 我正在尝试为自己和我的客户建立自己的CMS。 The system will mainly be used for small websites < 10 pages. 该系统主要用于<10页的小型网站。 For bigger project I will most likely use an existing system(MojoPortals, Umbraco, Kooboo). 对于更大的项目,我很可能会使用现有系统(MojoPortals,Umbraco,Kooboo)。 The reason why I want my own system is so that I have full control and also because existing systems are mostly bloated with features that I wont use anyway for smaller projects. 我之所以需要我自己的系统,是因为我有完全的控制权,而且因为现有的系统大多数都是膨胀的功能,我不会用于小型项目。 I am also learning Asp.net Mvc so that's the other reason to build my own system. 我也在学习Asp.net Mvc,这是构建我自己的系统的另一个原因。

These are some of the systems I tried(some more than others): 这些是我尝试过的一些系统(比其他系统更多):

The one I liked right away was MojoPortals. 我喜欢的那个是MojoPortals。 Mostly because of the left-middle-right + modules system. 主要是因为左中右+模块系统。

So my goals are to have a system where you can create pages and each page will have a left, middle and right placeholder for modules. 因此,我的目标是建立一个可以创建页面的系统,每个页面都有一个左侧,中间和右侧的模块占位符。 The modules will be very basic(Text, Html, Image). 模块将是非常基本的(文本,Html,图像)。 The system also need to be easy to deploy and reuse. 该系统还需要易于部署和重用。

I already started working on my system. 我已经开始研究我的系统了。

The page object looks like this: 页面对象如下所示:

public class Page
{
    public int PageID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public string Title { get; set; }
    public IEnumerable<Module> Modules { get; set; }
}

The Module object looks like this: Module对象如下所示:

public class Module
{
    public int ModuleID { get; set; }
    public string ModuleTitle { get; set; }
    public string ModuleType { get; set; }
    public string ModuleLocation { get; set; }
    public Dictionary<string, string> ModuleValues { get; set; }
}

This is how my View looks: www.codepaste.com 这就是我的View的样子: www.codepaste.com

Later I will probably add a website object that holds info for which view(template) it will show. 稍后我可能会添加一个网站对象,其中包含将显示哪个视图(模板)的信息。

The questions I have at the moment are mainly about the view. 我现在的问题主要是关于这个观点。 The view I linked has some basic code which first checks the module location and then shows all the module info in the right location. 我链接的视图有一些基本代码,首先检查模块位置,然后在正确的位置显示所有模块信息。 I would like that part to be easy reusable. 我希望那部分易于重复使用。 So I thought of making a strongly typed partial view that does the left, right and middle stuff. 所以我想到制作一个强类型的局部视图来做左,右和中间的东西。 Also for the modules I was thinking of using partial views and render the correct partial of a certain moduleType. 对于模块我也考虑使用部分视图并渲染某个moduleType的正确部分。 So text will have a partial, html will have one and so on. 所以文本会有部分,html会有一个等等。 I am not sure if this is the right technique. 我不确定这是否是正确的技术。

So should I use a partial view to handle the left, middle and right stuff and use partial views to load the modules? 那么我应该使用局部视图来处理左,中,右东西并使用局部视图来加载模块吗?

If somebody has other info about building a module based cms or techniques/structures that I can use that would be really great too. 如果有人有关于构建基于模块的cms或技术/结构的其他信息,我可以使用它也会非常棒。

Thanks in advance, Pickels. 提前谢谢,Pickels。

Yes, that's the best option. 是的,那是最好的选择。 Set a "structural base" to each template with css, and make every module load his own views into the right template sections. 使用css为每个模板设置“结构基础”,并使每个模块将自己的视图加载到正确的模板部分。 Lets say you template has a top menu under the common header where you display companie's logo and stuff .. insert in the database the information about the module and about that top section of the template (you should totally create a table in the database about template structure, so the system can know where to put every module related with every page), and just use the system to get the module needed in every page request to the right position, making it load its own view(s) into that place. 假设您的模板在公共标题下有一个顶级菜单,您可以在其中显示公司的徽标和内容。在数据库中插入有关模块和模板顶部的信息(您应该在数据库中完全创建一个关于模板的表结构,因此系统可以知道每个模块与每个页面相关的位置,并且只需使用系统将每个页面请求所需的模块放到正确的位置,使其将自己的视图加载到该位置。

Hope you understand my writing :) 希望你理解我的写作:)

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

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