Skip to main content
Home  › ... 2sxc Apps

Data Tutorials

Tutorial Home

Example from DNN Data

DNN also provides a lot of data about users, pages etc. In this example, we'll list all the pages (tabs) in DNN and mark the one we're on. Please note that the DNN API isn't very consistent - so sometimes things use ID, sometimes Id, so best really verify the exact names as spelled in the API.


@{#if NETCOREAPP}
  @Html.Partial("../shared/_MessageOqtaneDisabled.cshtml")
@{#else}
@{
  // get the pages
  var pages = DotNetNuke.Entities.Tabs.TabController.GetPortalTabs(CmsContext.Site.Id, 0, true, false);
  var current = DotNetNuke.Entities.Tabs.TabController.CurrentPage;
}

<ul>
  @foreach(DotNetNuke.Entities.Tabs.TabInfo dnnPage in pages) {
    <li class='@(dnnPage.TabID == current.TabID ? "selected" : "")'>
      <a href="@dnnPage.FullUrl" target="_blank">
        @dnnPage.TabName (#@dnnPage.TabID)
      </a>
    </li>
  }
</ul>

@{#endif}

Source Code of this file

Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code

@inherits Custom.Hybrid.Razor14
<!-- unimportant stuff, hidden -->
@using System.Collections.Generic;
Example from DNN Data DNN also provides... <!-- unimportant stuff, hidden -->

@{#if NETCOREAPP}
  @Html.Partial("../shared/_MessageOqtaneDisabled.cshtml")
@{#else}
@{
  // get the pages
  var pages = DotNetNuke.Entities.Tabs.TabController.GetPortalTabs(CmsContext.Site.Id, 0, true, false);
  var current = DotNetNuke.Entities.Tabs.TabController.CurrentPage;
}





<ul>
  @foreach(DotNetNuke.Entities.Tabs.TabInfo dnnPage in pages) {
    <li class='@(dnnPage.TabID == current.TabID ? "selected" : "")'>
      <a href="@dnnPage.FullUrl" target="_blank">
        @dnnPage.TabName (#@dnnPage.TabID)
      </a>
    </li>
  }
</ul>

@{#endif}



<!-- unimportant stuff, hidden -->