Autogenerate a 404 page if theme is missing 404.php
This commit is contained in:
parent
2a84b6512b
commit
e90d312170
@ -43,7 +43,12 @@ function get_site_url($echo = true) {
|
||||
*/
|
||||
function get_page_title($echo = true) {
|
||||
$db = getdatabase();
|
||||
$title = $db->get("pages", "title", ["AND" => ["slug" => getpageslug(), "siteid" => getsiteid()]]);
|
||||
$slug = getpageslug();
|
||||
if (is_null($slug)) {
|
||||
$title = "404 Page Not Found";
|
||||
} else {
|
||||
$title = $db->get("pages", "title", ["AND" => ["slug" => $slug, "siteid" => getsiteid()]]);
|
||||
}
|
||||
if ($echo) {
|
||||
echo $title;
|
||||
}
|
||||
@ -152,7 +157,20 @@ function get_page_url($echo = true, $slug = null) {
|
||||
function get_component($name, $context = null, $echo = true, $default = "") {
|
||||
$db = getdatabase();
|
||||
if ($context == null) {
|
||||
$context = get_page_slug(false);
|
||||
$context = getpageslug();
|
||||
if ($context == null) {
|
||||
$context = "404";
|
||||
}
|
||||
}
|
||||
if ($context == "404") {
|
||||
if ($name == "content") {
|
||||
if ($echo) {
|
||||
echo "The requested page could not be found.";
|
||||
}
|
||||
return "The requested page could not be found.";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
$pageid = $db->get("pages", "pageid", ["AND" => ["slug" => $context, "siteid" => getsiteid()]]);
|
||||
$content = "";
|
||||
@ -198,7 +216,10 @@ function is_component_empty($name, $context = null) {
|
||||
function get_complex_component($name, $context = null, $include = []) {
|
||||
$db = getdatabase();
|
||||
if ($context == null) {
|
||||
$context = get_page_slug(false);
|
||||
$context = getpageslug();
|
||||
if ($context == "404") {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
$pageid = $db->get("pages", "pageid", ["AND" => ["slug" => $context, "siteid" => getsiteid()]]);
|
||||
$content = ["icon" => "", "link" => "", "text" => ""];
|
||||
@ -595,6 +616,7 @@ define("SPECIAL_TYPE_PHONE", 1);
|
||||
define("SPECIAL_TYPE_EMAIL", 2);
|
||||
define("SPECIAL_TYPE_LINEBREAKS", 3);
|
||||
define("SPECIAL_TYPE_ADDRESS", 4);
|
||||
|
||||
/**
|
||||
* Take $text, format it according to $type,
|
||||
* replace [[CONTENT]] in $template with it,
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?php include __DIR__ . "/inc/header.inc.php"; ?>
|
||||
<div class="no-sidebar">
|
||||
<div id="page-wrapper">
|
||||
<?php include __DIR__ . "/inc/nav.inc.php"; ?>
|
||||
|
||||
<!-- Main -->
|
||||
<div id="main-wrapper">
|
||||
<div class="container">
|
||||
<div id="content">
|
||||
<article>
|
||||
<h2>404 Page Not Found</h2>
|
||||
<p>The requested page could not be found.</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include __DIR__ . "/inc/footer.inc.php"; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php include __DIR__ . "/inc/scripts.inc.php"; ?>
|
Loading…
x
Reference in New Issue
Block a user