Skip to content

Instantly share code, notes, and snippets.

@Edarlingen
Last active May 22, 2024 11:08
Show Gist options
  • Save Edarlingen/7fed69d4b3f910b15dcf to your computer and use it in GitHub Desktop.
Save Edarlingen/7fed69d4b3f910b15dcf to your computer and use it in GitHub Desktop.
Хлебные крошки в Netcat.
<?php
$url = $nc_core->catalogue->get_url_by_id($catalogue);
$full_url_without_query = $url . $nc_core->url->get_parsed_url('path');
$h1 = $nc_core->page->get_h1();
$breadcrumb_position = 1;
$current_cc_subdivision_id = $current_cc['Subdivision_ID'] ?: 0;
?>
<ol class='breadcrumb' itemscope='' itemtype='https://schema.org/BreadcrumbList'>
<li itemprop='itemListElement' itemscope='' itemtype='https://schema.org/ListItem'>
<a itemprop='item' href='<?= $url; ?>/'>
<span itemprop='name'>Главная</span>
<meta itemprop='position' content='<?= $breadcrumb_position; ?>' />
</a>
</li>
<? foreach ($nc_core->nav->get_path(1) as $sd): ?>
<? if (property_exists($sd, 'id')): ?>
<? $breadcrumb_position++; ?>
<? if (($action !== 'full' && $current_cc_subdivision_id === $sd->id) || ($action !== 'full' && !$cc)): ?>
<li itemprop='itemListElement' itemscope='' itemtype='https://schema.org/ListItem' class='active'>
<a itemprop='item' href='<?= $url . $sd->url ?>'>
<span itemprop='name'><?= $sd->name ?></span>
<meta itemprop='position' content='<?= $breadcrumb_position; ?>' />
</a>
</li>
<? else: ?>
<li itemprop='itemListElement' itemscope='' itemtype='https://schema.org/ListItem'>
<a itemprop='item' href='<?= $url . $sd->url ?>'>
<span itemprop='name'><?= $sd->name ?></span>
<meta itemprop='position' content='<?= $breadcrumb_position; ?>' />
</a>
</li>
<? endif; ?>
<? if ($action === 'full' && $current_cc_subdivision_id === $sd->id): ?>
<li itemprop='itemListElement' itemscope='' itemtype='https://schema.org/ListItem' class='active'>
<a itemprop='item' href='<?= $full_url_without_query; ?>'>
<span itemprop='name'><?= $h1; ?></span>
<meta itemprop='position' content='<?= $breadcrumb_position + 1; ?>' />
</a>
</li>
<? endif; ?>
<? endif; ?>
<? endforeach; ?>
<? if ($action === 'full'): ?>
<li itemprop='itemListElement' itemscope='' itemtype='https://schema.org/ListItem'>
<a itemprop='item' href='<?= $full_url_without_query; ?>'>
<span itemprop='name'><?= $h1; ?></span>
<meta itemprop='position' content='<?= $breadcrumb_position + 1; ?>' />
</a>
</li>
<? endif; ?>
</ol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment