Use actual twig variables for the page body
Replaces <!--AntCMS-Body--> with {{ AntCMSBody | raw }}
This commit is contained in:
parent
e2ca10d51d
commit
e1667b6374
|
@ -23,8 +23,6 @@ class AntCMS
|
||||||
$this->renderException("404");
|
$this->renderException("404");
|
||||||
}
|
}
|
||||||
|
|
||||||
$markdown = AntMarkdown::renderMarkdown($content['content']);
|
|
||||||
|
|
||||||
$pageTemplate = $this->getPageLayout(null, $page);
|
$pageTemplate = $this->getPageLayout(null, $page);
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
|
@ -32,8 +30,8 @@ class AntCMS
|
||||||
'AntCMSDescription' => $content['description'],
|
'AntCMSDescription' => $content['description'],
|
||||||
'AntCMSAuthor' => $content['author'],
|
'AntCMSAuthor' => $content['author'],
|
||||||
'AntCMSKeywords' => $content['keywords'],
|
'AntCMSKeywords' => $content['keywords'],
|
||||||
|
'AntCMSBody' => AntMarkdown::renderMarkdown($content['content']),
|
||||||
);
|
);
|
||||||
$pageTemplate = str_replace('<!--AntCMS-Body-->', $markdown, $pageTemplate);
|
|
||||||
$pageTemplate = AntTwig::renderWithTiwg($pageTemplate, $params);
|
$pageTemplate = AntTwig::renderWithTiwg($pageTemplate, $params);
|
||||||
|
|
||||||
$end_time = microtime(true);
|
$end_time = microtime(true);
|
||||||
|
@ -78,8 +76,8 @@ class AntCMS
|
||||||
$exceptionString = $exceptionString . " (Code $exceptionCode)";
|
$exceptionString = $exceptionString . " (Code $exceptionCode)";
|
||||||
$pageTemplate = self::getPageLayout();
|
$pageTemplate = self::getPageLayout();
|
||||||
|
|
||||||
$pageTemplate = str_replace('<!--AntCMS-Title-->', 'An error ocurred', $pageTemplate);
|
$pageTemplate = str_replace('{{ AntCMSTitle }}', 'An error ocurred', $pageTemplate);
|
||||||
$pageTemplate = str_replace('<!--AntCMS-Body-->', '<h1>An error ocurred</h1><p>' . $exceptionString . '</p>', $pageTemplate);
|
$pageTemplate = str_replace('{{ AntCMSBody | raw }} ', '<h1>An error ocurred</h1><p>' . $exceptionString . '</p>', $pageTemplate);
|
||||||
|
|
||||||
http_response_code($httpCode);
|
http_response_code($httpCode);
|
||||||
echo $pageTemplate;
|
echo $pageTemplate;
|
||||||
|
@ -150,7 +148,7 @@ class AntCMS
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>AntCMS had an error when fetching the page template, please contact the site administrator.</p>
|
<p>AntCMS had an error when fetching the page template, please contact the site administrator.</p>
|
||||||
<!--AntCMS-Body-->
|
{{ AntCMSBody | raw }}
|
||||||
</body>
|
</body>
|
||||||
</html>';
|
</html>';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,20 +38,19 @@ class AdminPlugin extends AntPlugin
|
||||||
$this->managePages($route);
|
$this->managePages($route);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
$HTMLTemplate = "<h1>AntCMS Admin Plugin</h1>\n";
|
||||||
|
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/config/'>AntCMS Configuration</a><br>\n";
|
||||||
|
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/'>Page management</a><br>\n";
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'AntCMSTitle' => 'AntCMS Admin Dashboard',
|
'AntCMSTitle' => 'AntCMS Admin Dashboard',
|
||||||
'AntCMSDescription' => 'The AntCMS admin dashboard',
|
'AntCMSDescription' => 'The AntCMS admin dashboard',
|
||||||
'AntCMSAuthor' => 'AntCMS',
|
'AntCMSAuthor' => 'AntCMS',
|
||||||
'AntCMSKeywords' => '',
|
'AntCMSKeywords' => '',
|
||||||
|
'AntCMSBody' => $HTMLTemplate,
|
||||||
);
|
);
|
||||||
|
|
||||||
$HTMLTemplate = "<h1>AntCMS Admin Plugin</h1>\n";
|
echo AntTwig::renderWithTiwg($pageTemplate, $params);
|
||||||
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/config/'>AntCMS Configuration</a><br>\n";
|
|
||||||
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/'>Page management</a><br>\n";
|
|
||||||
$pageTemplate = str_replace('<!--AntCMS-Body-->', $HTMLTemplate, $pageTemplate);
|
|
||||||
$pageTemplate = AntTwig::renderWithTiwg($pageTemplate, $params);
|
|
||||||
|
|
||||||
echo $pageTemplate;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,10 +115,8 @@ class AdminPlugin extends AntPlugin
|
||||||
$HTMLTemplate .= "</ul>\n";
|
$HTMLTemplate .= "</ul>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$pageTemplate = str_replace('<!--AntCMS-Body-->', $HTMLTemplate, $pageTemplate);
|
$params['AntCMSBody'] = $HTMLTemplate;
|
||||||
$pageTemplate = AntTwig::renderWithTiwg($pageTemplate, $params);
|
echo AntTwig::renderWithTiwg($pageTemplate, $params);
|
||||||
|
|
||||||
echo $pageTemplate;
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,10 +244,8 @@ class AdminPlugin extends AntPlugin
|
||||||
$HTMLTemplate .= "</ul>\n";
|
$HTMLTemplate .= "</ul>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$pageTemplate = str_replace('<!--AntCMS-Body-->', $HTMLTemplate, $pageTemplate);
|
$params['AntCMSBody'] = $HTMLTemplate;
|
||||||
$pageTemplate = AntTwig::renderWithTiwg($pageTemplate, $params);
|
echo AntTwig::renderWithTiwg($pageTemplate, $params);
|
||||||
|
|
||||||
echo $pageTemplate;
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<div class="col-md-10"><!--AntCMS-Body--></div>
|
<div class="col-md-10">{{ AntCMSBody | raw }}</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<div class="container mx-auto my-4">
|
<div class="container mx-auto my-4">
|
||||||
<div class="flex flex-wrap -mx-4">
|
<div class="flex flex-wrap -mx-4">
|
||||||
<div class="w-1/12"></div>
|
<div class="w-1/12"></div>
|
||||||
<div class="w-10/12 prose dark:prose-invert max-w-none"><!--AntCMS-Body--></div>
|
<div class="w-10/12 prose dark:prose-invert max-w-none">{{ AntCMSBody | raw }}</div>
|
||||||
<div class="w-1/12"></div>
|
<div class="w-1/12"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue