landing page editing

This commit is contained in:
Flatlogic Bot 2026-03-08 03:22:33 +00:00
parent 1173fcbe16
commit 6485678cb7
4 changed files with 51 additions and 43 deletions

1
.session_id Normal file
View File

@ -0,0 +1 @@
jbuvnmdmjhe702uecv5o643pb7

View File

@ -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');
<div class="mb-3">
<label class="form-label">Content (HTML allowed)</label>
<textarea name="content" class="form-control" rows="5"><?= e($editSection['content'] ?? '') ?></textarea>
<small class="text-muted">Not applicable for most built-in sections.</small>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">Layout Type</label>
<select name="layout" class="form-select">
<select name="layout" class="form-select" <?= ($editSection['section_type'] ?? 'custom') !== 'custom' ? 'disabled' : '' ?>>
<option value="text_left" <?= ($editSection['layout'] ?? '') === 'text_left' ? 'selected' : '' ?>>Text Left, Image Right</option>
<option value="text_right" <?= ($editSection['layout'] ?? '') === 'text_right' ? 'selected' : '' ?>>Image Left, Text Right</option>
<option value="center" <?= ($editSection['layout'] ?? '') === 'center' ? 'selected' : '' ?>>Center (No Image)</option>
@ -184,15 +192,17 @@ render_header(t('app_name') . ' - Landing Pages', 'admin');
<div class="list-group-item list-group-item-action d-flex justify-content-between align-items-center p-3">
<div>
<h6 class="mb-1 fw-bold"><?= e($sec['title']) ?> <span class="badge bg-<?= $sec['is_active'] ? 'success' : 'secondary' ?> ms-2"><?= $sec['is_active'] ? 'Active' : 'Draft' ?></span></h6>
<small class="text-muted">Order: <?= e($sec['section_order']) ?> | Layout: <?= e($sec['layout']) ?></small>
<small class="text-muted">Order: <?= e($sec['section_order']) ?> | Type: <?= e(ucfirst($sec['section_type'])) ?> <?= $sec['section_type']==='custom' ? '| Layout: '.e($sec['layout']) : '' ?></small>
</div>
<div class="d-flex gap-2">
<a href="<?= e(url_with_lang('admin_landing_pages.php', ['edit' => $sec['id']])) ?>" class="btn btn-sm btn-outline-primary">Edit</a>
<?php if ($sec['section_type'] === 'custom'): ?>
<form action="<?= e(url_with_lang('admin_landing_pages.php')) ?>" method="POST" onsubmit="return confirm('Are you sure you want to delete this section?');" style="display:inline;">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="<?= e($sec['id']) ?>">
<button type="submit" class="btn btn-sm btn-outline-danger">Delete</button>
</form>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>

View File

@ -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,

View File

@ -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'):
?>
<div class="hero-section mb-5">
<div class="row g-0">
<div class="col-lg-6 d-flex flex-column justify-content-center">
@ -39,10 +44,10 @@ render_header(t('app_name'), 'home');
<?= e(t('hero_tagline')) ?>
</span>
<h1 class="display-5 fw-bold mb-4" style="line-height: 1.2;">
<?= e(t('hero_title')) ?>
<?= e($sec['title'] ?: t('hero_title')) ?>
</h1>
<p class="fs-5 text-muted mb-5">
<?= e(t('hero_subtitle')) ?>
<?= e($sec['subtitle'] ?: t('hero_subtitle')) ?>
</p>
<div class="d-flex flex-column flex-sm-row gap-3">
<a class="btn btn-primary btn-lg shadow-sm" href="<?= e(url_with_lang('register.php', ['role' => 'shipper'])) ?>">
@ -61,12 +66,15 @@ render_header(t('app_name'), 'home');
</div>
</div>
<div class="col-lg-6">
<div class="hero-img-container" style="background-image: url('assets/images/hero_trucks.jpg');"></div>
<div class="hero-img-container" style="background-image: url('<?= $sec['image_path'] ? e($sec['image_path']) : 'assets/images/hero_trucks.jpg' ?>');"></div>
</div>
</div>
</div>
<?php elseif ($sec['section_type'] === 'stats'): ?>
<div class="row mb-5 g-4">
<?php if ($sec['title']): ?>
<div class="col-12 text-center mb-3"><h2 class="display-6 fw-bold"><?= e($sec['title']) ?></h2></div>
<?php endif; ?>
<div class="col-md-4">
<div class="stat-card">
<div class="fs-4"><?= e($stats['shipments']) ?>+</div>
@ -86,20 +94,18 @@ render_header(t('app_name'), 'home');
</div>
</div>
</div>
<?php elseif ($sec['section_type'] === 'features'): ?>
<section class="mb-5">
<div class="text-center mb-5">
<h2 class="display-6 fw-bold mb-3"><?= e(t('why_choose_us')) ?></h2>
<p class="text-muted fs-5 mx-auto" style="max-width: 600px;"><?= e(t('motivation_phrase')) ?></p>
<h2 class="display-6 fw-bold mb-3"><?= e($sec['title'] ?: t('why_choose_us')) ?></h2>
<p class="text-muted fs-5 mx-auto" style="max-width: 600px;"><?= e($sec['subtitle'] ?: t('motivation_phrase')) ?></p>
</div>
<div class="row g-4">
<div class="col-md-4">
<div class="panel p-4 h-100 text-center border-0 shadow-sm">
<div class="feature-icon mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-lightning-charge" viewBox="0 0 16 16">
<path d="M11.251.068a.5.5 0 0 1 .227.58L9.677 6.5H13a.5.5 0 0 1 .364.843l-8 8.5a.5.5 0 0 1-.842-.49L6.323 9.5H3a.5.5 0 0 1-.364-.843l8-8.5a.5.5 0 0 1 .615-.09zM4.157 8.5H7a.5.5 0 0 1 .478.647L6.11 13.59l5.732-6.09H9a.5.5 0 0 1-.478-.647L9.89 2.41 4.157 8.5z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-lightning-charge" viewBox="0 0 16 16"><path d="M11.251.068a.5.5 0 0 1 .227.58L9.677 6.5H13a.5.5 0 0 1 .364.843l-8 8.5a.5.5 0 0 1-.842-.49L6.323 9.5H3a.5.5 0 0 1-.364-.843l8-8.5a.5.5 0 0 1 .615-.09zM4.157 8.5H7a.5.5 0 0 1 .478.647L6.11 13.59l5.732-6.09H9a.5.5 0 0 1-.478-.647L9.89 2.41 4.157 8.5z"/></svg>
</div>
<h4 class="fw-bold mb-3"><?= e(t('feature_1_title')) ?></h4>
<p class="text-muted mb-0"><?= e(t('feature_1_desc')) ?></p>
@ -108,10 +114,7 @@ render_header(t('app_name'), 'home');
<div class="col-md-4">
<div class="panel p-4 h-100 text-center border-0 shadow-sm">
<div class="feature-icon mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-shield-check" viewBox="0 0 16 16">
<path d="M5.338 1.59a61.44 61.44 0 0 0-2.837.856.481.481 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.725 10.725 0 0 0 2.287 2.233c.346.244.652.42.893.533.12.057.218.095.293.118a.55.55 0 0 0 .101.025.615.615 0 0 0 .1-.025c.076-.023.174-.061.294-.118.24-.113.547-.29.893-.533a10.726 10.726 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.775 11.775 0 0 1-2.517 2.453 7.159 7.159 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7.158 7.158 0 0 1-1.048-.625 11.777 11.777 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 62.456 62.456 0 0 1 5.072.56z"/>
<path d="M10.854 5.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 7.793l2.646-2.647a.5.5 0 0 1 .708 0z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-shield-check" viewBox="0 0 16 16"><path d="M5.338 1.59a61.44 61.44 0 0 0-2.837.856.481.481 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.725 10.725 0 0 0 2.287 2.233c.346.244.652.42.893.533.12.057.218.095.293.118a.55.55 0 0 0 .101.025.615.615 0 0 0 .1-.025c.076-.023.174-.061.294-.118.24-.113.547-.29.893-.533a10.726 10.726 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.775 11.775 0 0 1-2.517 2.453 7.159 7.159 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7.158 7.158 0 0 1-1.048-.625 11.777 11.777 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 62.456 62.456 0 0 1 5.072.56z"/><path d="M10.854 5.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 7.793l2.646-2.647a.5.5 0 0 1 .708 0z"/></svg>
</div>
<h4 class="fw-bold mb-3"><?= e(t('feature_2_title')) ?></h4>
<p class="text-muted mb-0"><?= e(t('feature_2_desc')) ?></p>
@ -120,9 +123,7 @@ render_header(t('app_name'), 'home');
<div class="col-md-4">
<div class="panel p-4 h-100 text-center border-0 shadow-sm">
<div class="feature-icon mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-people" viewBox="0 0 16 16">
<path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8Zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022ZM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816ZM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0Zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-people" viewBox="0 0 16 16"><path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8Zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022ZM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816ZM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0Zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z"/></svg>
</div>
<h4 class="fw-bold mb-3"><?= e(t('feature_3_title')) ?></h4>
<p class="text-muted mb-0"><?= e(t('feature_3_desc')) ?></p>
@ -130,15 +131,15 @@ render_header(t('app_name'), 'home');
</div>
</div>
</section>
<?php elseif ($sec['section_type'] === 'workflow'): ?>
<section class="mb-5">
<div class="row g-4 align-items-center">
<div class="col-md-6 order-md-2">
<img src="assets/images/workflow_trucks.jpg" alt="Logistics" class="img-fluid rounded-4 shadow-sm" style="width: 100%; object-fit: cover; height: 350px;">
<img src="<?= $sec['image_path'] ? e($sec['image_path']) : 'assets/images/workflow_trucks.jpg' ?>" alt="Logistics" class="img-fluid rounded-4 shadow-sm" style="width: 100%; object-fit: cover; height: 350px;">
</div>
<div class="col-md-6 order-md-1">
<div class="p-lg-4">
<h2 class="display-6 fw-bold mb-4"><?= e(t('section_workflow')) ?></h2>
<h2 class="display-6 fw-bold mb-4"><?= e($sec['title'] ?: t('section_workflow')) ?></h2>
<div class="d-flex mb-4">
<div class="flex-shrink-0">
@ -173,11 +174,11 @@ render_header(t('app_name'), 'home');
</div>
</div>
</section>
<?php elseif ($sec['section_type'] === 'recent_shipments'): ?>
<?php if ($recentShipments): ?>
<section class="panel p-4 mb-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h2 class="section-title mb-0"><?= e(t('recent_shipments')) ?></h2>
<h2 class="section-title mb-0"><?= e($sec['title'] ?: t('recent_shipments')) ?></h2>
<a class="btn btn-outline-primary btn-sm rounded-pill px-3" href="<?= e(url_with_lang('register.php', ['role' => 'shipper'])) ?>"><?= e(t('cta_shipper')) ?></a>
</div>
@ -215,32 +216,26 @@ render_header(t('app_name'), 'home');
</div>
</section>
<?php endif; ?>
<?php elseif ($sec['section_type'] === 'faq'): ?>
<section class="mb-5 text-center">
<div class="panel p-5 border-0 shadow-sm rounded-4" style="background-color: #f8f9fa;">
<h2 class="display-6 fw-bold mb-3">Have Questions?</h2>
<p class="text-muted fs-5 mb-4 mx-auto" style="max-width: 600px;">Check out our Frequently Asked Questions to learn more about how our platform works.</p>
<h2 class="display-6 fw-bold mb-3"><?= e($sec['title'] ?: 'Have Questions?') ?></h2>
<p class="text-muted fs-5 mb-4 mx-auto" style="max-width: 600px;"><?= e($sec['subtitle'] ?: 'Check out our Frequently Asked Questions to learn more about how our platform works.') ?></p>
<a href="<?= e(url_with_lang('faq.php')) ?>" class="btn btn-primary btn-lg px-4 rounded-pill shadow-sm">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-question-circle me-2" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/><path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/></svg>View FAQ
</a>
</div>
</section>
<div class="motivation-box mb-5">
<h3 class="display-6 fw-bold mb-3">Ready to transform your logistics?</h3>
<p class="fs-5 text-white-50 mb-4 mx-auto" style="max-width: 600px;">Join our platform today to find reliable trucks or secure the best shipments in the market.</p>
<?php elseif ($sec['section_type'] === 'motivation'): ?>
<div class="motivation-box mb-5" <?php if ($sec['image_path']) { echo 'style="background-image: url(' . e($sec['image_path']) . '); background-size: cover; background-position: center;"'; } ?>>
<h3 class="display-6 fw-bold mb-3"><?= e($sec['title'] ?: 'Ready to transform your logistics?') ?></h3>
<p class="fs-5 text-white-50 mb-4 mx-auto" style="max-width: 600px;"><?= e($sec['subtitle'] ?: 'Join our platform today to find reliable trucks or secure the best shipments in the market.') ?></p>
<div class="d-flex flex-wrap justify-content-center gap-3">
<a class="btn btn-light btn-lg px-4 text-primary fw-bold" href="<?= e(url_with_lang('register.php', ['role' => 'shipper'])) ?>"><?= e(t('register_shipper')) ?></a>
<a class="btn btn-outline-light btn-lg px-4 fw-bold" href="<?= e(url_with_lang('register.php', ['role' => 'truck_owner'])) ?>"><?= e(t('register_owner')) ?></a>
</div>
</div>
<?php
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):
?>
<?php elseif ($sec['section_type'] === 'custom'): ?>
<section class="mb-5">
<?php if ($sec['layout'] === 'center'): ?>
<div class="panel p-5 border-0 shadow-sm rounded-4 text-center" style="background-color: #f8f9fa;">
@ -282,6 +277,7 @@ try {
</div>
<?php endif; ?>
</section>
<?php endif; ?>
<?php
endforeach;
} catch (Throwable $e) {}