prepare("INSERT INTO landing_sections (title, title_ar, subtitle, subtitle_ar, content, content_ar, image_path, layout, button_text, button_text_ar, button_link, section_order, is_active, section_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'custom')"); $stmt->execute([$title, $title_ar, $subtitle, $subtitle_ar, $content, $content_ar, $image_path, $layout, $button_text, $button_text_ar, $button_link, $section_order, $is_active]); set_flash('success', 'Section created successfully.'); } else { $stmt = $pdo->prepare("UPDATE landing_sections SET title=?, title_ar=?, subtitle=?, subtitle_ar=?, content=?, content_ar=?, image_path=?, layout=?, button_text=?, button_text_ar=?, button_link=?, section_order=?, is_active=? WHERE id=?"); $stmt->execute([$title, $title_ar, $subtitle, $subtitle_ar, $content, $content_ar, $image_path, $layout, $button_text, $button_text_ar, $button_link, $section_order, $is_active, $id]); set_flash('success', 'Section updated successfully.'); } header('Location: ' . url_with_lang('admin_landing_pages.php')); exit; } elseif ($action === 'delete') { $id = $_POST['id'] ?? null; if ($id) { $stmt = $pdo->prepare("SELECT section_type FROM landing_sections WHERE id=?"); $stmt->execute([$id]); $sec = $stmt->fetch(); if ($sec && $sec['section_type'] !== 'custom') { set_flash('danger', 'Built-in sections cannot be deleted, but you can hide them by unchecking Active.'); } else { $stmt = $pdo->prepare("DELETE FROM landing_sections WHERE id=?"); $stmt->execute([$id]); set_flash('success', 'Section deleted successfully.'); } } header('Location: ' . url_with_lang('admin_landing_pages.php')); exit; } } $stmt = $pdo->query("SELECT * FROM landing_sections ORDER BY section_order ASC, id ASC"); $sections = $stmt->fetchAll(); $editId = $_GET['edit'] ?? null; $editSection = null; if ($editId) { $stmt = $pdo->prepare("SELECT * FROM landing_sections WHERE id = ?"); $stmt->execute([$editId]); $editSection = $stmt->fetch(); } render_header(t('app_name') . ' - Landing Pages', 'admin', true); ?>
No custom sections added yet.