Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where Breadcrumbs had invalid metadata for disabled pages #4671

Merged
merged 11 commits into from
May 25, 2021
33 changes: 20 additions & 13 deletions DNN Platform/Website/admin/Skins/BreadCrumb.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public partial class BreadCrumb : SkinObjectBase

public BreadCrumb()
{
this._navigationManager = Globals.DependencyProvider.GetRequiredService<INavigationManager>();
this._navigationManager = Globals.DependencyProvider.GetRequiredService<INavigationManager>();
this.LegacyMode = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.LegacyMode = true;

}

public int ProfileUserId
Expand Down Expand Up @@ -89,7 +90,12 @@ public string RootLevel
public bool UseTitle { get; set; }

// Do not show when there is no breadcrumb (only has current tab)
public bool HideWithNoBreadCrumb { get; set; }
public bool HideWithNoBreadCrumb { get; set; }

/// <summary>
/// Gets or sets a value indicating whether set this to false in the skin to take advantage of the enhanced markup.
/// </summary>
public bool LegacyMode { get; set; }
Andy9999 marked this conversation as resolved.
Show resolved Hide resolved

protected override void OnLoad(EventArgs e)
{
Expand Down Expand Up @@ -172,21 +178,22 @@ protected override void OnLoad(EventArgs e)
tabUrl = this._navigationManager.NavigateURL(tab.TabID, string.Empty, "GroupId=" + this.GroupId);
}

// Begin breadcrumb
this._breadcrumb.Append("<span itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\">");

// Is this tab disabled? If so, only render the text
// Is this tab disabled? If so, only render a span
if (tab.DisableLink)
{
this._breadcrumb.Append("<span class=\"" + this._cssClass + "\" itemprop=\"name\">" + tabName + "</span>");
{
if (this.LegacyMode)
this._breadcrumb.Append("<span><span class=\"" + this._cssClass + "\">" + tabName + "</span></span>");
else
this._breadcrumb.Append("<span class=\"" + this._cssClass + "\">" + tabName + "</span>");
Andy9999 marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
this._breadcrumb.Append("<a href=\"" + tabUrl + "\" class=\"" + this._cssClass + "\" itemprop=\"item\"><span itemprop=\"name\">" + tabName + "</span></a>");
{
// An enabled page, render the breadcrumb
this._breadcrumb.Append("<span itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\">");
this._breadcrumb.Append("<a href=\"" + tabUrl + "\" class=\"" + this._cssClass + "\" itemprop=\"item\"><span itemprop=\"name\">" + tabName + "</span></a>");
this._breadcrumb.Append("<meta itemprop=\"position\" content=\"" + position++ + "\" />"); // Notice we post-increment the position variable
this._breadcrumb.Append("</span>");
}

this._breadcrumb.Append("<meta itemprop=\"position\" content=\"" + position++ + "\" />"); // Notice we post-increment the position variable
this._breadcrumb.Append("</span>");
}

this._breadcrumb.Append("</span>"); // End of BreadcrumbList
Expand Down