Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс
This commit is contained in:
commit
f6ba0d2174
470 files changed
+26454
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jinove\Vinoteca;
|
||||
|
||||
use Bitrix\Main\Localization\Loc;
|
||||
|
||||
Loc::loadMessages(__FILE__);
|
||||
|
||||
class Breadcrumbs
|
||||
{
|
||||
public static function show(array $items): void
|
||||
{
|
||||
global $APPLICATION;
|
||||
|
||||
$APPLICATION->AddChainItem((string)Loc::getMessage("VINO_BREADCRUMBS_HOME"), SITE_DIR);
|
||||
foreach ($items as $item) {
|
||||
$link = (string)($item[1] ?? "");
|
||||
if ($link !== "" && str_starts_with($link, "/") && !str_starts_with($link, SITE_DIR)) {
|
||||
$link = SITE_DIR . ltrim($link, "/");
|
||||
}
|
||||
$APPLICATION->AddChainItem((string)$item[0], $link);
|
||||
}
|
||||
$APPLICATION->IncludeComponent("bitrix:breadcrumb", "vinoteca", [
|
||||
"START_FROM" => "0",
|
||||
"PATH" => "",
|
||||
"SITE_ID" => SITE_ID,
|
||||
], false, ["HIDE_ICONS" => "Y"]);
|
||||
}
|
||||
|
||||
public static function schema(array $chain, string $self): array
|
||||
{
|
||||
$last = count($chain) - 1;
|
||||
$items = [];
|
||||
foreach ($chain as $i => $item) {
|
||||
$link = (string)$item["LINK"];
|
||||
$items[] = [
|
||||
"@type" => "ListItem",
|
||||
"position" => $i + 1,
|
||||
"name" => $item["TITLE"],
|
||||
"item" => $i < $last && $link !== "" ? Config::host() . $link : $self,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
"@context" => "https://schema.org",
|
||||
"@type" => "BreadcrumbList",
|
||||
"@id" => $self . "#breadcrumb",
|
||||
"itemListElement" => $items,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user