简体   繁体   English

整个网站部分作为 DotNetNuke 模块

[英]A whole website section as a DotNetNuke module

I need to develop a whole section of a website (around 10 different pages) as a DotNetNuke module.我需要开发一个网站的整个部分(大约 10 个不同的页面)作为 DotNetNuke 模块。 The site will be using DNN as the CMS, where editors will manage HTML content for most of the website (exception that section I'll be developing).该网站将使用 DNN 作为 CMS,编辑将在其中管理大部分网站的 HTML 内容(我将开发的部分除外)。

I've already made a rather extensive research on DNN Module Development (even watched some recorded Webinars by DNN Corp).我已经对 DNN 模块开发进行了相当广泛的研究(甚至观看了 DNN Corp 录制的一些网络研讨会)。 Unfortunately, most of what I could find online is about developing simple, widget-like modules.不幸的是,我在网上能找到的大部分内容都是关于开发简单的、类似小部件的模块。 Also, most of it uses a step-by-step "how to use visual studio to acomplish x" approach, while I was trying to understand how DNN works.此外,其中大部分使用分步“如何使用 Visual Studio 完成 x”的方法,而我试图了解 DNN 的工作原理。 So it seems I have to figure it out for myself...所以看来我得自己想办法了……

At this point I'm already somewhat familiar with DNN, and I see several different solutions to my problem:在这一点上,我已经对 DNN 有点熟悉,并且我看到了几种不同的解决方案来解决我的问题:

  1. Creating a module for every page on my custom section.为我的自定义部分的每个页面创建一个模块。 I don't like this idea very much, specially because I have code that need to be shared across multiple pages.我不太喜欢这个想法,特别是因为我有需要跨多个页面共享的代码。
  2. Developing a single module with several User Controls inside (one for each page), and use custom module settings to let each page know which control to display.开发包含多个用户控件的单个模块(每个页面一个),并使用自定义模块设置让每个页面知道要显示哪个控件。
  3. Develop a "bogus" module that will work as a library, and additional modules for each page.开发一个“假”模块,作为一个库工作,并为每个页面添加额外的模块。
  4. Develop the library module, then use the Razor Host Module and Razor scripts for the views (I don't need/want WebForms on my app).开发库模块,然后将 Razor 主机模块和 Razor 脚本用于视图(我不需要/想要在我的应用程序上使用 WebForms)。

So I decided to ask you guys for advice.所以我决定向大家征求意见。 Which is the the preferred way to go? go 的首选方式是哪种? Maybe none of the above?也许以上都没有? I know all four options above should give me the result I want, but I also don't want to go against the "DNN way" too much...我知道上面的所有四个选项都应该给我想要的结果,但我也不想 go 反对“DNN 方式”太多......

I wouldn't recommend #1 (multiple modules) or #3 (also multiple modules) at all, and though #2 (single module w/ module level setting that determines view) is definitely a solid option used widely by DNN module developers, it sounds like you'd prefer #4 (Razor) over #2 because you like the development style.我根本不推荐#1(多个模块)或#3(也是多个模块),尽管#2(确定视图的具有模块级别设置的单个模块)绝对是DNN模块开发人员广泛使用的可靠选项,听起来你更喜欢#4(Razor)而不是#2,因为你喜欢开发风格。

So - I'd recommend going with the Razor approach, which though it seems like you understand the approach just fine, I wanted to elaborate on for posterity:所以-我建议使用 Razor 方法,尽管您似乎很好地理解了该方法,但我想为后代详细说明:

  • Build a library (assembly/DLL) to encapsulate all of your reusable business logic构建一个库(程序集/DLL)来封装所有可重用的业务逻辑
  • Build out Razor views for each page that make use of that logic and render your data on the page为每个使用该逻辑的页面构建 Razor 视图并在页面上呈现您的数据
  • Drop the Razor Host module on each page that you need it and point it to the correct view将 Razor 主机模块放在您需要的每个页面上,并将其指向正确的视图

That should work out quite well.这应该会很好。

I'm assuming you're looking at developing your software in the "Web Site Project" style.我假设您正在考虑以“网站项目”风格开发您的软件。 I'll like to recommend that you look at the "Web Application Project" style of doing things.我会推荐你看看“Web 应用程序项目”的做事风格。

If you have shared functionality in a library, feel free to build an assembly and drop it in the bin folder, from there, it will be picked up by DNN and it will run in the http context, which is great!如果您在库中共享功能,请随意构建一个程序集并将其放入 bin 文件夹,从那里,DNN 将拾取它,它将在 http 上下文中运行,这很棒!

Build your module in one project and package the different modules in your DNN manifest.在一个项目中构建您的模块,并在您的 DNN 清单中构建不同的模块。

Hope i'm not talking about what you understand.希望我不是在谈论你所理解的。


Added another answer, it's a post in itself.添加了另一个答案,它本身就是一个帖子。

Modules - That's a term that's very loosely used by all of us.模块 - 这是一个我们所有人都非常松散地使用的术语。

Clearer Definitions更清晰的定义

  • Package = Zip file (Not Module) Package = Zip 文件(非模块)
  • Manifest =.DNN file清单 =.DNN 文件

The manifest allows you to define Modules(group of View/Edit/Settings) user controls as a single installation package.清单允许您将模块(查看/编辑/设置组)用户控件定义为单个安装 package。

In the DNN 3.0 manifest, if you're still in this format, you'll notice that a basic single installation package is structured like this (briefly)在 DNN 3.0 清单中,如果您仍然采用这种格式,您会注意到一个基本的单一安装 package 的结构是这样的(简要)

<dotnetnuke version="3.0" type="Module">
  <folders>
    <folder>
      <name>Side bar Navigation</name>
      <modules>
        <module>
          <friendlyname></friendlyname>
          <cachetime>0</cachetime>
          <controls>
            <control>
              <title>View</title>
              <src>DesktopModules/Module/View.ascx</src>
              <type>View</type>
            </control>
            <control>
              <key>Settings</key>
              <title>Settings</title>
              <src>DesktopModules/Module/Settings.ascx</src>
              <type>Edit</type>
            </control>
          </controls>
        </module>
      </modules>
      <files>
          ...
      </files>
    </folder>
</folders>
</dotnetnuke>

So that above defines a Single Module in an Installation Package.因此,上面定义了安装 Package 中的单个模块。

In the context of a blog, you would have 2 modules在博客的上下文中,您将有 2 个模块

  1. Blog Display Module (displays a selected blog or just the whole lot)博客显示模块(显示选定的博客或全部)
  2. Sidebar Navigation Module (Helps you to display quickly the blogs you've written for an any period of time)侧边栏导航模块(帮助您快速显示您撰写的任何时间的博客)

What you can do is to package the Blog Display Module in the manifest in a copy of <folder></folder> and then the Sidebar Navigation Module in another copy of the <folder></folder> structure.您可以做的是将清单中的博客显示模块 package 放在<folder></folder>的副本中,然后将侧边栏导航模块放在<folder></folder>结构的另一个副本中。

For example, this project has 7 modules;比如这个项目有7个模块; Side bar navigation, custom search module, blah blah blah侧边栏导航,自定义搜索模块,等等等等

<dotnetnuke version="3.0" type="Module">
  <folders>
    <folder>...</folder>
    <folder>...</folder>
    <folder>...</folder>
    <folder>...</folder>
    <folder>...</folder>
    <folder>...</folder>
    <folder>...</folder>
  </folders>
</dotnetnuke>
  1. 1 Installation Package (Which means 1 Web App Project) 1 安装Package(即1 Web App Project)
  2. 7 Modules 7 个模块
  3. One assembly to place in the bin/一个组件放入垃圾箱/
  4. All code is shared and you can then inherit from other library references to develop further.所有代码都是共享的,然后您可以从其他库引用继承以进一步开发。

They have different views, names, friendlynames but all share one common <foldername>它们有不同的视图、名称、友好名称,但都共享一个共同的<foldername>

The KEY is in the Packaging.关键在包装中。

   <folder>
      <name>BlogDisplay</name>
      <friendlyname>Blog Display</friendlyname>
      <foldername>WebLog</foldername>
      <modulename></modulename>'

   '<folder>
      <name>BlogSidebar</name>
      <friendlyname>Sidebar Navigator</friendlyname>
      <foldername>WebLog</foldername>
      <modulename></modulename>

It'll look something like this.它看起来像这样。 that's where foldername is.那就是文件夹名称所在的位置。 It defines where in DesktopModules your module will be installed to.它定义了您的模块在 DesktopModules 中的安装位置。

In DNN 5 books, the Web Site Project method of development is still in use but when you're participating in development on the Core Modules, you'll find that the projects are in Web App Project development style, which is better, because all your code-behind is in an assembly and not exposed as source code on the web.在 DNN 5 书籍中,Web Site Project 的开发方法仍在使用,但是当您参与 Core Modules 的开发时,您会发现项目采用 Web App Project 开发风格,更好,因为所有您的代码隐藏在程序集中,而不是作为 web 上的源代码公开。

You're definitely on the right path.你绝对是在正确的道路上。

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

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