Edit Page fixes
This commit is contained in:
@@ -50,7 +50,7 @@ EOSQL;
|
||||
if (empty($pageid)) {
|
||||
// New page: set default values for all fields
|
||||
$data['rows'] = [
|
||||
'id' => '',
|
||||
'id' => 'newpage',
|
||||
'title' => '',
|
||||
'heading' => '',
|
||||
'description' => '',
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user