page names ending in 'd'
Caught an error that was causing pages that end in 'd' to not function properly. The issue was on line96 of managepages.php
:
$pagename = rtrim(explode('/',$file)[5], '.md');
Replaced that line with the following code to check and account for page names like 'download' and 'legend':
$parts = explode('/', $file);
$filename = $parts[5];
if (substr($filename, -1) === 'd') {
$pagename = substr($filename, 0, -3);
} else {
$pagename = rtrim($filename, '.md');
}
Update:
I also had to account for this in sidebar.php
when displaying and linking to the pages. Same code to replace/use.
Update #2
I also needed to update 404.php
and page.php
with the following code, in each case replaying the existing foreach
sections:
page.php
// foreach(glob($root.'/pages/*.md') as $file) {
// $pagename = rtrim(explode('/',$file)[5], '.md');
// if ($pagename == $page) {
// $match = true;
// }
// }
foreach(glob($root.'/pages/*.md') as $file) {
$filename = basename($file);
if (substr($filename, -1) === 'd') {
$pagename = substr($filename, 0, -3);
} else {
$pagename = rtrim($filename, '.md');
}
if ($pagename == $page) {
$match = true;
}
}
404.php
// foreach(glob($root.'/pages/'.'*.md') as $i=>$file) {
// $pagenames[$i] = rtrim(explode('/',$file)[5], '.md');
// }
foreach(glob($root.'/pages/'.'*.md') as $i => $file) {
$filename = basename($file);
if (substr($filename, -1) === 'd') {
$pagename = substr($filename, 0, -3);
} else {
$pagename = rtrim($filename, '.md');
}
$pagenames[$i] = $pagename;
}
Update #3
And, admin.php
for the NOWNS section:
foreach(glob($pages.'*.md') as $i=>$file) {
// $pagename = rtrim(explode('/',$file)[5], '.md');
$parts = explode('/', $file);
$filename = $parts[5];
if (substr($filename, -1) === 'd') {
$pagename = substr($filename, 0, -3);
} else {
$pagename = rtrim($filename, '.md');
}
Comments
Have something you'd like to respond with? 📣
Send me a note via email and let's start a conversation on this very topic.