Fix breadcrumb navigation for directories
- Breadcrumb items for directories are now only clickable if an index file exists - Prevents 404 errors when clicking on folder names in breadcrumb - Non-clickable directory items are shown as active text - Improves navigation UX and prevents broken links
This commit is contained in:
parent
a6461abede
commit
231c73c5af
@ -320,7 +320,15 @@ class CodePressCMS {
|
|||||||
if ($i === count($parts) - 1) {
|
if ($i === count($parts) - 1) {
|
||||||
$breadcrumb .= '<li class="breadcrumb-item active">' . $title . '</li>';
|
$breadcrumb .= '<li class="breadcrumb-item active">' . $title . '</li>';
|
||||||
} else {
|
} else {
|
||||||
$breadcrumb .= '<li class="breadcrumb-item"><a href="?page=' . $path . '">' . $title . '</a></li>';
|
// Check if directory has index file
|
||||||
|
$dirPath = $this->config['content_dir'] . '/' . $path;
|
||||||
|
$hasIndex = file_exists($dirPath . '/index.md') || file_exists($dirPath . '/index.php') || file_exists($dirPath . '/index.html');
|
||||||
|
|
||||||
|
if ($hasIndex) {
|
||||||
|
$breadcrumb .= '<li class="breadcrumb-item"><a href="?page=' . $path . '/index">' . $title . '</a></li>';
|
||||||
|
} else {
|
||||||
|
$breadcrumb .= '<li class="breadcrumb-item active" aria-current="page">' . $title . '</li>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user