Edit Page fixes

This commit is contained in:
2025-11-08 10:28:13 -08:00
parent a459b86169
commit 869c3a8d6a
4 changed files with 147 additions and 51 deletions

View File

@@ -43,21 +43,7 @@ if (empty($title) || empty($slug) || empty($body)) {
}
try {
if (!empty($id)) {
// Update existing page
$query = "UPDATE `pages` SET
`title` = ?, `heading` = ?, `description` = ?, `keywords` = ?, `author` = ?,
`slug` = ?, `path` = ?, `intro` = ?, `body` = ?, `notes` = ?,
`draft` = ?, `changefreq` = ?, `priority` = ?, `updated` = NOW()
WHERE `id` = ?";
$params = [
$title, $heading, $description, $keywords, $author,
$slug, $path, $intro, $body, $notes,
$draft, $changefreq, $priority, $id
];
$db->query($query, $params);
$messages->notice('Page Updated');
} else {
if ($id == 'newpage') {
// Create new page
$query = "INSERT INTO `pages`
(`title`, `heading`, `description`, `keywords`, `author`,
@@ -72,7 +58,26 @@ try {
$db->query($query, $params);
$id = $db->lastid; // Get new page ID
$messages->notice('Page Created');
$newpage = true;
} else {
$newpage = false;
}
if (!empty($id) && !$newpage) {
// Update existing page
$query = "UPDATE `pages` SET
`title` = ?, `heading` = ?, `description` = ?, `keywords` = ?, `author` = ?,
`slug` = ?, `path` = ?, `intro` = ?, `body` = ?, `notes` = ?,
`draft` = ?, `changefreq` = ?, `priority` = ?, `updated` = NOW()
WHERE `id` = ?";
$params = [
$title, $heading, $description, $keywords, $author,
$slug, $path, $intro, $body, $notes,
$draft, $changefreq, $priority, $id
];
$db->query($query, $params);
$messages->notice('Page Updated');
}
} catch (Exception $e) {
$messages->error($e->getMessage());
$redirect->url($url_error);