Added the ability to toggle page visibility

This commit is contained in:
Belle Aerni 2023-01-17 19:23:48 -08:00
parent 0eca5dd3e1
commit f388c99647
2 changed files with 21 additions and 2 deletions

View file

@ -30,7 +30,7 @@ class AntPages
);
$pageList[] = $currentPage;
}
AntYaml::saveFile(antPagesList, $pageList);
}
@ -71,6 +71,11 @@ class AntPages
$url = "//" . AntTools::repairURL($baseURL . $page['functionalPagePath']);
$pages[$key]['url'] = $url;
$pages[$key]['active'] = $currentPage === strtolower($page['functionalPagePath']);
//Remove pages that are hidden from the nav from the array before sending it to twig.
if (!(bool)$page['showInNav']) {
unset($pages[$key]);
}
}
$antTwig = new AntTwig;

View file

@ -211,6 +211,20 @@ class AdminPlugin extends AntPlugin
header('Location: //' . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/");
break;
case 'togglevisibility':
array_shift($route);
$pagePath = AntTools::repairFilePath(antContentPath . '/' . implode('/', $route));
foreach ($pages as $key => $page) {
if ($page['fullPagePath'] == $pagePath) {
$pages[$key]['showInNav'] = !$page['showInNav'];
}
}
AntYaml::saveFile(antPagesList, $pages);
header('Location: //' . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/");
break;
default:
$HTMLTemplate = "<h1>Page Management</h1>\n";
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/regenerate'>Click here to regenerate the page list</a><br>\n";
@ -224,7 +238,7 @@ class AdminPlugin extends AntPlugin
$HTMLTemplate .= "<ul>\n";
$HTMLTemplate .= "<li>Full page path: " . $page['fullPagePath'] . "</li>\n";
$HTMLTemplate .= "<li>Functional page path: " . $page['functionalPagePath'] . "</li>\n";
$HTMLTemplate .= "<li>Show in navbar: " . $this->boolToWord($page['showInNav']) . "</li>\n";
$HTMLTemplate .= "<li>Show in navbar: <a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/togglevisibility" . $page['functionalPagePath'] . "'>". $this->boolToWord($page['showInNav']) . "</a></li><br>\n";
$HTMLTemplate .= "</ul>\n";
$HTMLTemplate .= "</li>\n";
}