Thursday, October 14, 2010

DotNetNuke - Display all sub tabs of the current page in a list in C#

The following code snippet will display all of the sub pages of the current page (that the current user is allowed to see). This can be useful if you are building your own menu provider, or would like to build some redundancy to make things easier for a user to find pages on your site. Code is provided in C#.

lblItems.Text = "<ul>";
foreach (TabInfo tab in TabController.GetTabsByParent(this.TabId, this.PortalId))
    if ((tab.IsVisible)&&(!tab.IsDeleted) && (DotNetNuke.Security.Permissions.TabPermissionController.CanViewPage(tab)))
        lblItems.Text = lblItems.Text + "<li><a href=\"" + tab.TabPath.Replace("//", "/") + ".aspx\">" + tab.TabName + "</a>";
lblItems.Text = lblItems.Text + "</ul>";

No comments:

Post a Comment