mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-02-13 15:28:41 +00:00
Draft highlight active link
This commit is contained in:
parent
f214030702
commit
a063704c55
|
|
@ -19,11 +19,16 @@ if (isset($this->nav[\Modules\Navigation\Models\NavigationType::CONTENT])
|
||||||
) {
|
) {
|
||||||
echo '<div class="row"><div class="col-xs-12"><ul class="nav-top" role="navigation">';
|
echo '<div class="row"><div class="col-xs-12"><ul class="nav-top" role="navigation">';
|
||||||
|
|
||||||
|
$uriPath = $this->request->getUri()->getPath();
|
||||||
|
|
||||||
foreach ($this->nav[\Modules\Navigation\Models\NavigationType::CONTENT] as $key => $parent) {
|
foreach ($this->nav[\Modules\Navigation\Models\NavigationType::CONTENT] as $key => $parent) {
|
||||||
foreach ($parent as $link) {
|
foreach ($parent as $link) {
|
||||||
if ($link['nav_parent'] === $this->parent) {
|
if ($link['nav_parent'] === $this->parent) {
|
||||||
echo '<li><a href="' . \phpOMS\Uri\UriFactory::build($link['nav_uri']) . '">'
|
$uri = \phpOMS\Uri\UriFactory::build($link['nav_uri']);
|
||||||
. $this->getHtml($link['nav_name'], 'Navigation') . '</a>';
|
echo '<li'
|
||||||
|
. (\stripos($uri, $uriPath) !== false ? ' class="active"' : '')
|
||||||
|
. '><a href="' . $uri . '">'
|
||||||
|
. $this->getHtml($link['nav_name'], 'Navigation') . '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,16 @@
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
*/
|
*/
|
||||||
|
use \Modules\Navigation\Models\LinkType;
|
||||||
|
use \Modules\Navigation\Models\NavigationType;
|
||||||
/**
|
/**
|
||||||
* @var \Modules\Navigation\Views\NavigationView $this
|
* @var \Modules\Navigation\Views\NavigationView $this
|
||||||
*/
|
*/
|
||||||
if (isset($this->nav[\Modules\Navigation\Models\NavigationType::SIDE])) : ?>
|
if (isset($this->nav[NavigationType::SIDE])) : ?>
|
||||||
<ul id="nav-side" class="nav" role="navigation">
|
<ul id="nav-side" class="nav" role="navigation">
|
||||||
<?php foreach ($this->nav[\Modules\Navigation\Models\NavigationType::SIDE][\Modules\Navigation\Models\LinkType::CATEGORY] as $key => $parent) : ?>
|
<?php
|
||||||
|
$uriPath = $this->request->getUri()->getPath();
|
||||||
|
foreach ($this->nav[NavigationType::SIDE][LinkType::CATEGORY] as $key => $parent) : ?>
|
||||||
<li><input id="nav-<?= $this->printHtml($parent['nav_name']); ?>" type="checkbox">
|
<li><input id="nav-<?= $this->printHtml($parent['nav_name']); ?>" type="checkbox">
|
||||||
<ul>
|
<ul>
|
||||||
<li><label for="nav-<?= $this->printHtml($parent['nav_name']); ?>">
|
<li><label for="nav-<?= $this->printHtml($parent['nav_name']); ?>">
|
||||||
|
|
@ -24,15 +28,23 @@ if (isset($this->nav[\Modules\Navigation\Models\NavigationType::SIDE])) : ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?= $this->getHtml($parent['nav_name'], 'Navigation') ?><i class="fa fa-chevron-left min"></i>
|
<?= $this->getHtml($parent['nav_name'], 'Navigation') ?><i class="fa fa-chevron-left min"></i>
|
||||||
<i class="fa fa-chevron-down max"></i></label>
|
<i class="fa fa-chevron-down max"></i></label>
|
||||||
<?php if (isset($this->nav[\Modules\Navigation\Models\NavigationType::SIDE][\Modules\Navigation\Models\LinkType::LINK])) :
|
<?php if (isset($this->nav[NavigationType::SIDE][LinkType::LINK])) :
|
||||||
foreach ($this->nav[\Modules\Navigation\Models\NavigationType::SIDE][\Modules\Navigation\Models\LinkType::LINK] as $key2 => $link) :
|
foreach ($this->nav[NavigationType::SIDE][LinkType::LINK] as $key2 => $link) :
|
||||||
if ($link['nav_parent'] === $key) : ?>
|
if ($link['nav_parent'] === $key) :
|
||||||
<li>
|
$uri = \phpOMS\Uri\UriFactory::build($link['nav_uri']);
|
||||||
<a href="<?= \phpOMS\Uri\UriFactory::build($link['nav_uri']); ?>"><?= $this->getHtml($link['nav_name'], 'Navigation') ?></a>
|
$parentUri = \explode('/', $uri);
|
||||||
<?php endif;
|
\array_pop($parentUri);
|
||||||
endforeach; endif; ?>
|
$miniParent = \ltrim(\implode('/', $parentUri), '/') . '/';
|
||||||
|
// todo: very simpleminded solution. doesn't work for root path /en/backend etc. e.g. dashboard
|
||||||
|
// this also fails for urls which are not structured like a tree
|
||||||
|
?>
|
||||||
|
<li<?= (count($parentUri) > 2 && \stripos($uriPath, $miniParent) !== false) ? ' class="active"' : '' ?>>
|
||||||
|
<a href="<?= $uri; ?>"><?= $this->getHtml($link['nav_name'], 'Navigation') ?></a>
|
||||||
|
<?php endif;
|
||||||
|
endforeach;
|
||||||
|
endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user