Move nav layout to it's own file

This commit is contained in:
Belle Aerni 2023-01-07 02:02:51 -08:00
parent d5e19ecf4d
commit d3798cceca
3 changed files with 12 additions and 11 deletions

View file

@ -21,14 +21,15 @@ class AntCMS
}
$markdown = AntMarkdown::renderMarkdown($content['content']);
$pageTemplate = $this->getThemeContent();
$theme = $this->getThemeContent();
$pageTemplate = $theme['default_layout'];
$pageTemplate = str_replace('<!--AntCMS-Description-->', $content['description'], $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-Author-->', $content['author'], $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-Keywords-->', $content['keywords'], $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-Title-->', $content['title'], $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-Navigation-->', AntPages::generateNavigation(null), $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-Navigation-->', AntPages::generateNavigation($theme['nav_layout']), $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-Body-->', $markdown, $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-SiteTitle-->', $siteInfo['siteTitle'], $pageTemplate);
@ -85,11 +86,12 @@ class AntCMS
public function getThemeContent()
{
$currentConfig = AntConfig::currentConfig();
$themePath = antThemePath . '/' . $currentConfig['activeTheme'] . "/default_layout.html";
$themeContent = file_get_contents($themePath);
$themePath = antThemePath . '/' . $currentConfig['activeTheme'];
$themeContent['default_layout'] = file_get_contents($themePath . '/default_layout.html');
$themeContent['nav_layout'] = file_get_contents($themePath . '/nav_layout.html') ?? '';
if (!$themeContent) {
$themeContent = '
if (!$themeContent['default_layout']) {
$themeContent['default_layout'] = '
<!DOCTYPE html>
<html>
<head>

View file

@ -40,14 +40,10 @@ class AntPages
return AntYaml::parseFile(antPagesList);
}
public static function generateNavigation($navTemplate = null)
public static function generateNavigation($navTemplate = '')
{
$currentConfig = AntConfig::currentConfig();
$baseURL = $currentConfig['baseURL'];
$navTemplate =
'<li class="nav-item active">
<a class="nav-link" href="<!--AntCMS-PageLink-->"><!--AntCMS-PageTitle--></a>
</li>';
$navHTML = '';
foreach (AntPages::getPages() as $page) {
if(!$page['showInNav']){

View file

@ -0,0 +1,3 @@
<li class="nav-item active">
<a class="nav-link" href="<!--AntCMS-PageLink-->"><!--AntCMS-PageTitle--></a>
</li>