public static function breadcrumbs($Data, $HomeLink = true, $Options = array())
{
$Format = '<a href="{Url,html}" itemprop="url"><span itemprop="title">{Name,html}</span></a>';
$Result = '';
if (!is_array($Data)) {
$Data = array();
}
if ($HomeLink) {
$HomeUrl = val('HomeUrl', $Options);
if (!$HomeUrl) {
$HomeUrl = Url('/', true);
}
$Row = array('Name' => $HomeLink, 'Url' => $HomeUrl, 'CssClass' => 'CrumbLabel HomeCrumb');
if (!is_string($HomeLink)) {
$Row['Name'] = T('Home');
}
array_unshift($Data, $Row);
}
if (val('HideLast', $Options)) {
// Remove the last item off the list.
array_pop($Data);
}
$DefaultRoute = ltrim(val('Destination', Gdn::router()->getRoute('DefaultController'), ''), '/');
$Count = 0;
$DataCount = 0;
$HomeLinkFound = false;
foreach ($Data as $Row) {
$DataCount++;
if ($HomeLinkFound && Gdn::request()->urlCompare($Row['Url'], $DefaultRoute) === 0) {
continue;
// don't show default route twice.
} else {
$HomeLinkFound = true;
}
// Add the breadcrumb wrapper.
if ($Count > 0) {
$Result .= '<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
}
$Row['Url'] = $Row['Url'] ? Url($Row['Url']) : '#';
$CssClass = 'CrumbLabel ' . val('CssClass', $Row);
if ($DataCount == count($Data)) {
$CssClass .= ' Last';
}
$Label = '<span class="' . $CssClass . '">' . formatString($Format, $Row) . '</span> ';
$Result = concatSep('<span class="Crumb">' . T('Breadcrumbs Crumb', '›') . '</span> ', $Result, $Label);
$Count++;
}
// Close the stack.
for ($Count--; $Count > 0; $Count--) {
$Result .= '</span>';
}
$Result = '<span class="Breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $Result . '</span>';
return $Result;
}