1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-08-04 23:57:30 +02:00

Showing directories having no 'index.md' in breadcrumbs (configurable)

This commit is contained in:
til-schneider
2015-12-28 15:14:43 +01:00
parent 6938b498a4
commit ffce00dece
5 changed files with 13 additions and 5 deletions

View File

@@ -36,6 +36,7 @@ body {
.breadcrumbs { .breadcrumbs {
background-color: white; background-color: white;
cursor: default;
.main-column { .main-column {
padding: 15px 0; padding: 15px 0;

View File

@@ -7,4 +7,7 @@ if (function_exists('date_default_timezone_set')) {
$config['wikiName'] = 'Slim Wiki'; $config['wikiName'] = 'Slim Wiki';
$config['lang'] = 'en'; // 'de' or 'en' $config['lang'] = 'en'; // 'de' or 'en'
// Hide directories having no 'index.md' in breadcrumbs
//$config['showCompleteBreadcrumbs'] = false;
//$config['footerHtml'] = '© Copyright 2000-'.date('Y').' My name'; //$config['footerHtml'] = '© Copyright 2000-'.date('Y').' My name';

View File

@@ -110,7 +110,7 @@ if ($mode == 'edit') {
if (! $isFirst) { if (! $isFirst) {
echo ' / '; echo ' / ';
} }
if ($item['active']) { if ($item['active'] || is_null($item['path'])) {
echo $item['name']; echo $item['name'];
} else { } else {
?><a href="<?php echo $data['basePath'] . $item['path'] . (($mode == 'edit') ? '?edit' : ''); ?>"><?php echo $item['name']; ?></a><?php ?><a href="<?php echo $data['basePath'] . $item['path'] . (($mode == 'edit') ? '?edit' : ''); ?>"><?php echo $item['name']; ?></a><?php

View File

@@ -28,7 +28,8 @@ class Context {
$config = array( $config = array(
'wikiName' => 'Slim Wiki', 'wikiName' => 'Slim Wiki',
'timezone' => 'Europe/Berlin', 'timezone' => 'Europe/Berlin',
'lang' => 'en' 'lang' => 'en',
'showCompleteBreadcrumbs' => true
); );
if (file_exists(__DIR__ . '/../../config.php')) { if (file_exists(__DIR__ . '/../../config.php')) {

View File

@@ -172,7 +172,9 @@ class Main {
} }
private function createBreadcrumbs($requestPathArray) { private function createBreadcrumbs($requestPathArray) {
$wikiName = $this->context->getConfig()['wikiName']; $config = $this->context->getConfig();
$wikiName = $config['wikiName'];
$showCompleteBreadcrumbs = $config['showCompleteBreadcrumbs'];
$pathCount = count($requestPathArray); $pathCount = count($requestPathArray);
$breadcrumbArray = array(array('name' => $wikiName, 'path' => '', 'active' => ($pathCount == 0))); $breadcrumbArray = array(array('name' => $wikiName, 'path' => '', 'active' => ($pathCount == 0)));
@@ -183,11 +185,12 @@ class Main {
$currentPath .= ($i == 0 ? '' : '/') . $pathPart; $currentPath .= ($i == 0 ? '' : '/') . $pathPart;
$isLast = ($i == $pathCount - 1); $isLast = ($i == $pathCount - 1);
if ($isLast || file_exists($articleBaseDir . $currentPath . '/index.md')) { $hasContent = ($isLast || file_exists($articleBaseDir . $currentPath . '/index.md'));
if ($hasContent || $showCompleteBreadcrumbs) {
// This is the requested file or an directory having an index -> Add it // This is the requested file or an directory having an index -> Add it
$breadcrumbArray[] = array( $breadcrumbArray[] = array(
'name' => str_replace('_', ' ', $pathPart), 'name' => str_replace('_', ' ', $pathPart),
'path' => urlencode($currentPath), 'path' => $hasContent ? urlencode($currentPath) : null,
'active' => $isLast); 'active' => $isLast);
} }
} }