withData([ 'title' => 'Novaconium Edit Page', 'pageclass' => 'novaconium', 'pageid' => 'controlPanel', 'editor' => 'ace' ]); // Check if logged in if (empty($ctx->session->get('username'))) { $ctx->messages->error('You are not logged in'); $ctx->redirect->url('/novaconium/login'); makeitso(); } // Get page ID from router parameters $pageid = $ctx->router->parameters['id'] ?? null; if (!empty($pageid)) { // Existing page: fetch from database $query = <<data['rows'] = $ctx->db->getRow($query, [$pageid]); // If no row is found, treat as new page if (!$ctx->data['rows']) { $pageid = null; } } if (empty($pageid)) { // New page: set default values for all fields $ctx->data['rows'] = [ 'id' => 'newpage', 'title' => '', 'heading' => '', 'description' => '', 'keywords' => '', 'author' => $ctx->session->get('username') ?? '', 'slug' => '', 'path' => '', 'intro' => '', 'body' => '', 'notes' => '', 'draft' => 0, 'changefreq' => 'monthly', 'priority' => 0.0, 'created' => date('Y-m-d H:i:s'), 'updated' => date('Y-m-d H:i:s') ]; } // Render the edit page view view('@novacore/editpage/index', $ctx->data);