如何获取DotNetNuke中除Admin选项卡之外的所有选项卡?

时间:2016-08-26 11:42:17

标签: asp.net c#-2.0

DotNetNuke.Common.Globals.GetPortalTabs(portalID, false, true, false, true, true) this function

此函数返回所有Tab列表....但我不想要Admin选项卡 ..也请帮帮我..

1 个答案:

答案 0 :(得分:1)

你的DNN多大了?自DNN 5.0以来DotNetNuke.Common.Globals.GetPortalTabs已被替换。

但这是一段代码片段,可以帮助您入门。

//get all the tabs in the current portal
List<DotNetNuke.Entities.Tabs.TabInfo> portalTabs = TabController.GetPortalTabs(PortalId, 0, true, false);

//loop all the tabs
foreach (TabInfo tabInfo in portalTabs)
{
    //get the TabPermission for the current tab and cast from Collection to List<TabPermissionInfo>
    List<DotNetNuke.Security.Permissions.TabPermissionInfo> tabPermissionInfo = DotNetNuke.Security.Permissions.TabPermissionController.GetTabPermissions(tabInfo.TabID, PortalId).Cast<DotNetNuke.Security.Permissions.TabPermissionInfo>().ToList();

    //filter out all the TabPermission with administrator using Linq
    List<TabPermissionInfo> tabPermissionInfoFiltered = tabPermissionInfo.Where(x => x.RoleName != "Administrators").ToList();

    //loop all the permissionInfo objects with administrator filtered out
    foreach (TabPermissionInfo permissionInfo in tabPermissionInfoFiltered)
    {
        Label1.Text += tabInfo.TabName + " - " + permissionInfo.RoleName + "<br>"; 
    }
}