bludit/bl-themes/docsx/php/sidebar.php

32 lines
933 B
PHP
Raw Normal View History

2018-02-06 23:11:50 +01:00
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
2018-02-08 00:20:00 +01:00
<div class="sidebar-sticky">
<?php
// Get all pages published
$pagesKeys = $dbPages->getPublishedDB();
foreach ($pagesKeys as $pageKey) {
// Build the page
$page = buildPage($pageKey);
2018-02-08 00:28:08 +01:00
// If the page is not a child this means the page is parent-page
2018-02-08 00:20:00 +01:00
if (!$page->isChild()) {
echo '<h6>'.$page->title().'</h6>';
2018-02-06 23:11:50 +01:00
2018-02-08 00:20:00 +01:00
// Get all children of the page
$childrenKeys = $page->children();
// Check if the page has children
if ($childrenKeys!==false) {
// Foreach child
2018-02-08 00:28:08 +01:00
echo '<ul class="nav flex-column">';
2018-02-08 00:20:00 +01:00
foreach ($childrenKeys as $childKey) {
// Build the child
$pageChild = buildPage($childKey);
echo '<li class="nav-item">';
2018-02-08 00:28:08 +01:00
echo '<a class="nav-link active" href="'.$pageChild->permalink().'">'.$pageChild->title().'</a>';
2018-02-08 00:20:00 +01:00
echo '</li>';
}
echo '</ul>';
}
}
}
?>
2018-02-06 23:11:50 +01:00
</div>
</nav>