DNN-提供基于会员资格的皮肤的最佳方式?

发布于 2025-01-01 16:33:06 字数 81 浏览 1 评论 0原文

我将在 dotnetnuke 中开发基于会员的门户。

同样,我希望允许门户管理员为用户定义皮肤。

告诉我我该怎么做?

I am going to develop membership based portal in dotnetnuke.

In the same I want to allow portal manager to define skins for users.

Tell me how can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∞觅青森が 2025-01-08 16:33:06

要根据用户的角色动态更改皮肤,查看此说明,来自 DotnetNuke.com:

有几种不同的方法可以动态地或以编程方式
更改特定页面加载的皮肤。 DotNetNuke 将首先查看
URL 中的覆盖值。如果找到特定值,则 DNN
将在该页面加载时加载该皮肤和/或容器。二、DNN
将查看本地 cookie 以查看是否定义了皮肤。
最后,如果前两种方法没有指定要加载的皮肤,DNN
将加载页面或站点定义的默认外观。活动中
该皮肤不存在,DNN 附带的默认皮肤将
已加载。

这就是为什么不要删除原来的皮肤包很重要
安装后。

可能是基于动态加载皮肤的最佳方法
安全角色是使用以下任一方法创建一个简单的 cookie:
DotNetNuke 模块,或 HttpModule。无论哪种方式,您都能够
检索用户信息,并基于 IsInSecurityRole()
属性,生成一个 cookie,该 cookie 将有效加载所需的皮肤。

在 Essence 中,在每个页面上放置的 DotNetNuke 模块中,您必须检查以下内容:

  1. 用户位于哪个门户?
  2. 用户处于哪个安全角色?
  3. 基于 1 & 2、用户应该看到哪种皮肤?

如果#3的答案是“非默认皮肤”,那么您将需要执行一些类似以下的代码,摘自DotNetNuke.com:

'import DotNetNuke.Entities.Users'
If Not Me.UserInfo Is Nothing AndAlso Me.UserInfo.UserID > Null.NullInteger Then
  If Me.UserInfo.IsInRole("My Security Role") Then
    ' import System.Web.HttpCookie 
    Response.Cookies.Add(New HttpCookie("SkinSrc", "[G]Skins/DarkKnight/Home-Mega-Menu.ascx"))
  Else
      ' either assign another skin, or do nothing 
  End If
Else
  ' either assign another skin, or do nothing 
End If

上面的代码片段显示了如何通过添加cookie键值来设置皮肤-一对。

我可能会将上述逻辑放入一个不可见的 DNN 模块中,并自动添加到网站上的所有页面;否则,您可以将逻辑注入到 Default.aspx 中(由于编辑 DNN 核心,不推荐)。

注意:PortalID 是每个模块项目中均可访问的字段。 Response.Write("我的门户 ID:" & PortalID.ToString())

To change the skin dynamically based upon the user's role, see this explanation, from DotnetNuke.com:

There are a few different ways to dynamically or programmatically
change the skin for a specific page load. DotNetNuke will look first
for an override value in the URL. If specific value is found, then DNN
will load that skin and/or container on that page load. Second, DNN
will look in a local cookie to see if there is a skin being defined.
Finally, if the first two methods did not specify a skin to load, DNN
will load the default skins defined by the page or site. In the event
that the skin doesn’t exist, the default skin that ships with DNN will
be loaded.

This is why it’s important to not delete the original skin package
after installing.

Probably the best way to approach dynamically loading a skin based on
security role would be to create a simple cookie using either a
DotNetNuke module, or HttpModule. Either way, you will be able to
retrieve the user information, and based on the IsInSecurityRole()
property, generate a cookie that will in effect load the desired skin.

In Essence, in a DotNetNuke Module placed on every page, you will have to check the following:

  1. Which portal is the user in?
  2. Which security role is the user in?
  3. Based upon 1 & 2, which skin should the user see?

If the answer to #3 is "a non-default skin", then you will need to execute some code like this, taken from DotNetNuke.com:

'import DotNetNuke.Entities.Users'
If Not Me.UserInfo Is Nothing AndAlso Me.UserInfo.UserID > Null.NullInteger Then
  If Me.UserInfo.IsInRole("My Security Role") Then
    ' import System.Web.HttpCookie 
    Response.Cookies.Add(New HttpCookie("SkinSrc", "[G]Skins/DarkKnight/Home-Mega-Menu.ascx"))
  Else
      ' either assign another skin, or do nothing 
  End If
Else
  ' either assign another skin, or do nothing 
End If

The above code snipped shows how to set the skin by adding a cookie key-value-pair.

I'd probably put the above logic into a DNN module that is invisible and is automatically added to all pages on the site; otherwise, you can probably inject the logic into Default.aspx (not recommended due to editing DNN core).

Note: PortalID is a field that is accessible in each module project. Response.Write("My Portal ID: " & PortalID.ToString())

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文