定制模块,可以将模块添加到模块中以在DNN 9.2中创建扩展器模块 [英] Custom module with possibility to add modules into module to create an expander module in DNN 9.2

查看:72
本文介绍了定制模块,可以将模块添加到模块中以在DNN 9.2中创建扩展器模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 DNN 9.2 ,并寻找一种可能性来创建自己的模块,该模块的工作方式类似于

​I'm using DNN 9.2 and searching for a possibility to create an own module that will work like the Atlassian Confluence's Expander Macro where I could add additional content. In my case I want to add other modules, which will be visible if the parent is expanded and hidden if the parent is collapsed. I thought about to use a Pane control in my module to place several other modules into it. It is an approach that imitates the Evoq's Grid module functionality, but with the additional possibility to collapse and expand its content, because of no such (expander) module already exists.

我已经尝试通过在 Page_Load 方法中的 DotNetNuke.UI.Skins 命名空间中添加 Pane 控件并调用来实现此目的pane.ProcessPane().正如我在数据库中看到的那样,通过将其移入我们的自定义( expander )模块来添加模块,该模块与位于模块中的窗格相关.实际上,通过加载和呈现页面,我遇到了一些问题,因为该模块位于自定义模块的下方,而不是在我们的自定义模块中,就像在数据库中引用的那样.

I already tried to achieve it by adding a Pane control from DotNetNuke.UI.Skins namespace in Page_Load method and calling pane.ProcessPane(). As I can see in database a added module by moving it into our custom (expander) module is related to our pane which is located in our module. Actually I have some problems by loading and rendering the page, because the module is located under and not in our custom module like it is referenced in database.

以下是我的实际代码:

在* .ascx文件中:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="View.ascx.cs" Inherits="Prototype.View" %>

<div ID="TestModuleDiv" runat="server"></div>

在* .ascx.cs(文件后面的代码)中:

using System;
using System.Web.UI.HtmlControls;
using DotNetNuke.Entities.Modules;
using DotNetNuke.UI.Skins;

protected void Page_Load(object sender, EventArgs e)
{
    var paneName = "MyTestPane" + ModuleContext.ModuleId;

    var paneControl = new HtmlGenericControl("div");
    paneControl.ID = paneName;

    TestModuleDiv.Controls.Add(paneControl);

    var paneId = paneControl.ClientID.Replace("dnn_", "");

    PortalSettings.ActiveTab.Panes.Add(paneId);

    var pane = new Pane(paneId, paneControl);
    pane.ProcessPane();
}

有人有更多信息可以帮助我实现自己想要的行为吗?

Does somebody have some more information how I could achieve my wanted behavior?

目标是创建一个扩展器模块,其中可以包含其他几个模块,但是我们不确定如何以最佳实践的方式构建它.

The aim is to create an expander module that could contain several other modules, but we are not sure how we could build it in a best practice way.

修改
抱歉,我错过了我正在寻找一种将JS魔术减至最少的方法的事实.因此,我认为它必须在后面的代码中发生.
此外,页面必须记住哪个"expander"模块已折叠以及哪个模块已展开.

Edit
Sorry, I missed the fact that I'm searching for an approach with minimized JS magic. Therefore I think it has to happen in code behind.
Furthermore the page must remember which "expander" module was collapsed and which expanded.

推荐答案

好吧,我们已经达到了一种可以像我们期望的那样工作的方法.

Well we have reached an approach that will work like we have expected.

整个添加/移动模块到扩展器模块中都是开箱即用的,并且会自动与DNN自身的功能配合使用.我们没有其他实现方法.

The whole adding/moving modules into the expander module works out of the box and automatically with DNN's own functionality side. We have nothing to implement additionally.

我们创建了一个自己的 Panel 控件,该控件继承自 HtmlContainerControl ) 从中.这一切都将在方法 OnInit 中发生.同样在 OnInit 方法中,注册了 OnInitComplete 方法.在这种方法中,我们将所有(先前添加的)模块移到窗格中.否则,添加了扩展器模块的模块将不会放置在扩展器内部,而是放置在其下方.之后,我们必须在活动选项卡中注册我们自己的窗格控件,并且必须最终在窗格上调用 ProcessPane .

We created an own Panel control that inherits from HtmlContainerControl and has some logic to use the parent skin as container and furthermore the parent module to get the active Tab (page) from it. This will all happen in method OnInit. Also in OnInit method the OnInitComplete methods is registered. In this method we are moving all (previously added) modules into the pane. Otherwise the expander module added modules will not be placed inside the expander, but under it. After that we have to register our own pane control in active tab and have to call finally ProcessPane on the pane.

我希望它能帮助需要类似东西的每个人.非常抱歉,我没有发布任何代码,但这是针对客户的实现,不允许我提供给第三方.

I hope it will help everybody who needs something similar. I'm very sorry for posting no code, but is an implementation for a customer which I'm not allowed to provide to third persons.

这篇关于定制模块,可以将模块添加到模块中以在DNN 9.2中创建扩展器模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆