1

Using 2sxc, I have a hero module that I use across the website on all pages. It looks like this:

enter image description here

It uses "@Content.Title" for the h1 tag so it displays "Scholarships". But I need to make a breadcrumb that gets the parent page's name of the current page. So in this case, "Teachers".

For example, this hero also exists on other pages like "Volunteer" and it has a parent of "Get Involved" so the breadcrumb would dynamically show "Get Involved".

So far, here's my code:

@if (@Dnn.Tab.ParentId != -1) {
                <nav class="uppercase text-sm font-semibold tracking-wider"><span class="text-honeydew visited:text-honeydew">@Dnn.Tab.ParentID</span> <span>/</span></nav>
                }

This works to handle heroes on a root page (to not show the breadcrumb). But I can only seem to output the ParentID.

How can I use the @Dnn.Tab.ParentID to get the Parent tab's name using c#? Or is there another way to go about this?

1 Answers1

1

Easiest thing to do is use the TabController to turn a TabId in to a TabInfo

@using DotNetNuke.Entities.Tabs

@functions {

  private TabInfo GetTabInfo(int tabId)
  {
    return TabController.Instance.GetTab(tabId, Dnn.Portal.PortalId);
  }

}

So then just call it all in one like this with .ParentId...

<pre>
Debug:

Parent Page Name: @GetTabInfo(Dnn.Tab.ParentId).TabName
</pre>
Jeremy Farrance
  • 740
  • 6
  • 11
  • I get an error like this: error CS1061: 'DotNetNuke.Entities.Tabs.TabInfo' does not contain a definition for 'ParentID' and no extension method 'ParentID' accepting a first argument of type 'DotNetNuke.Entities.Tabs.TabInfo' could be found (are you missing a using directive or an assembly reference?) – Aaron - Wolf X Machina Apr 06 '21 at 19:22
  • 2
    oops, its .ParentId, fixed above (I originally had .ParentID, gets confusing because there are a few places left in Dnn where is TabID and others where its TabId). – Jeremy Farrance Apr 06 '21 at 19:33