From 6485678cb7bb4ee9b63f4dad02a43b7bca3127fd Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 8 Mar 2026 03:22:33 +0000 Subject: [PATCH] landing page editing --- .session_id | 1 + admin_landing_pages.php | 22 +++++--- db/migrations/add_landing_sections.php | 1 + index.php | 70 ++++++++++++-------------- 4 files changed, 51 insertions(+), 43 deletions(-) create mode 100644 .session_id diff --git a/.session_id b/.session_id new file mode 100644 index 0000000..245e4c1 --- /dev/null +++ b/.session_id @@ -0,0 +1 @@ +jbuvnmdmjhe702uecv5o643pb7 \ No newline at end of file diff --git a/admin_landing_pages.php b/admin_landing_pages.php index 47ba94a..e05fddf 100644 --- a/admin_landing_pages.php +++ b/admin_landing_pages.php @@ -4,7 +4,7 @@ declare(strict_types=1); require_once __DIR__ . '/includes/app.php'; require_once __DIR__ . '/includes/layout.php'; -if (empty($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') { +if (empty($_SESSION['user_id']) || $_SESSION['user_role'] !== 'admin') { header('Location: ' . url_with_lang('login.php')); exit; } @@ -42,7 +42,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } if ($action === 'create') { - $stmt = $pdo->prepare("INSERT INTO landing_sections (title, subtitle, content, image_path, layout, button_text, button_link, section_order, is_active) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt = $pdo->prepare("INSERT INTO landing_sections (title, subtitle, content, image_path, layout, button_text, button_link, section_order, is_active, section_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'custom')"); $stmt->execute([$title, $subtitle, $content, $image_path, $layout, $button_text, $button_link, $section_order, $is_active]); set_flash('success', 'Section created successfully.'); } else { @@ -55,9 +55,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($action === 'delete') { $id = $_POST['id'] ?? null; if ($id) { - $stmt = $pdo->prepare("DELETE FROM landing_sections WHERE id=?"); + $stmt = $pdo->prepare("SELECT section_type FROM landing_sections WHERE id=?"); $stmt->execute([$id]); - set_flash('success', 'Section deleted successfully.'); + $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; @@ -120,12 +127,13 @@ render_header(t('app_name') . ' - Landing Pages', 'admin');
+ Not applicable for most built-in sections.
- > @@ -184,15 +192,17 @@ render_header(t('app_name') . ' - Landing Pages', 'admin');
- Order: | Layout: + Order: | Type:
Edit +
+
diff --git a/db/migrations/add_landing_sections.php b/db/migrations/add_landing_sections.php index eba5fdd..a5c949f 100644 --- a/db/migrations/add_landing_sections.php +++ b/db/migrations/add_landing_sections.php @@ -5,6 +5,7 @@ try { $pdo->exec(" CREATE TABLE IF NOT EXISTS landing_sections ( id INT AUTO_INCREMENT PRIMARY KEY, + section_type VARCHAR(50) NOT NULL DEFAULT 'custom', title VARCHAR(255) NOT NULL, subtitle TEXT NULL, content TEXT NULL, diff --git a/index.php b/index.php index bb66e79..dc8f101 100644 --- a/index.php +++ b/index.php @@ -29,8 +29,13 @@ try { } render_header(t('app_name'), 'home'); -?> +try { + $stmt = db()->query("SELECT * FROM landing_sections WHERE is_active = 1 ORDER BY section_order ASC, id ASC"); + $landingSections = $stmt->fetchAll(); + foreach ($landingSections as $sec): + if ($sec['section_type'] === 'hero'): +?>
@@ -39,10 +44,10 @@ render_header(t('app_name'), 'home');

- +

- +

-
+
- +
+ +

+
+
@@ -86,20 +94,18 @@ render_header(t('app_name'), 'home');
- +
-

-

+

+

- - - +

@@ -108,10 +114,7 @@ render_header(t('app_name'), 'home');
- - - - +

@@ -120,9 +123,7 @@ render_header(t('app_name'), 'home');
- - - +

@@ -130,15 +131,15 @@ render_header(t('app_name'), 'home');
- +
- Logistics + Logistics
-

+

@@ -173,11 +174,11 @@ render_header(t('app_name'), 'home');
- +
@@ -215,32 +216,26 @@ render_header(t('app_name'), 'home');
- +
-

Have Questions?

-

Check out our Frequently Asked Questions to learn more about how our platform works.

+

+

View FAQ
- -
-

Ready to transform your logistics?

-

Join our platform today to find reliable trucks or secure the best shipments in the market.

+ +
> +

+

- -query("SELECT * FROM landing_sections WHERE is_active = 1 ORDER BY section_order ASC, id ASC"); - $landingSections = $stmt->fetchAll(); - foreach ($landingSections as $sec): -?> +
@@ -282,6 +277,7 @@ try {
+