1
0
Fork 0
web-jbeyerstedt/site/snippets/base/cont-header.php

68 lines
2.4 KiB
PHP
Raw Permalink Normal View History

<?php
// -------------------------------------------
// kirby snippet FOR jannikbeyerstedt.de
// copyright: Jannik Beyerstedt | https://jannikbeyerstedt.de
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
// -------------------------------------------
$subnav = false;
if ($page->depth() == 1) {
$baseSec = $page;
2021-01-24 17:05:39 +00:00
if ( $page->isListed() && $baseSec->hasListedChildren() && $page->template() != 'blog' ) {
$subnav = true;
}
}else if ($page->depth() == 2) {
$baseSec = $page->parent();
2021-01-24 17:05:39 +00:00
if ( $page->isListed() && $baseSec->hasListedChildren() && $page->template() != 'blogarticle' ) {
$subnav = true;
}
}
?>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label class="d-sm-none" for="nav-trigger">Menü</label>
<nav class="mobile">
<ul class="nav mobileNav">
<li><a href="<?php echo $site->url()?>">Home</a></li>
2021-01-24 17:05:39 +00:00
<?php foreach ($site->children()->listed() as $p) : ?>
<li><a href="<?php echo $p->url()?>" <?php echo ($page == $p)?'class="active"':'' ?>><?php echo $p->title() ?></a></li>
2021-01-24 17:05:39 +00:00
<?php if ($p->hasListedChildren() && $p->template() != 'blog') : ?>
<ul class="">
2021-01-24 17:05:39 +00:00
<?php foreach ($p->children()->listed() as $c) : ?>
<li><a href="<?php echo $c->url()?>" <?php echo ($page == $c)?'class="active"':'' ?>><?php echo $c->title() ?></a></li>
2016-05-20 22:26:34 +00:00
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</nav>
<div class="site-wrap">
<header class="section">
<div class="container">
2022-08-10 13:17:42 +00:00
<?php if ($img = $site->title_image()->toFile()) : ?>
<a class="logo" href="<?php echo url() ?>">
2022-08-10 13:17:42 +00:00
<img src="<?php echo $img->url() ?>" alt="Logo">
</a>
2016-04-07 20:06:04 +00:00
<?php endif; ?>
<nav aria-hidden="true">
<ul class="nav d-none d-sm-block">
2016-05-20 22:26:34 +00:00
<?php if(!$subnav) : ?>
2021-01-24 17:05:39 +00:00
<?php foreach ($site->children()->listed() as $p) : ?>
<a href="<?php echo $p->url()?>" <?php echo ($page == $p || $page->parent() == $p)?'class="active"':'' ?>><li><?php echo $p->title() ?></li></a>
<?php endforeach; ?>
2016-05-20 22:26:34 +00:00
<?php else : ?>
<a href="<?php echo $baseSec->url()?>" class="section <?php echo ($page == $baseSec)?'active':'' ?>"><li><?php echo $baseSec->title() ?>:</li></a>
2021-01-24 17:05:39 +00:00
<?php foreach ($baseSec->children()->listed() as $p) : ?>
<a href="<?php echo $p->url()?>" <?php echo ($page == $p)?'class="active"':'' ?>><li><?php echo $p->title() ?></li></a>
<?php endforeach; ?>
<?php endif; ?>
2016-05-20 22:26:34 +00:00
</ul>
</nav>
</div>
</header>