2
This commit is contained in:
parent
41e158c880
commit
6f945035e3
@ -1 +1,24 @@
|
|||||||
{"hero_title": "Build Your Dream Website", "hero_subtitle": "Visually design, customize, and publish beautiful, responsive websites. No code required."}
|
{
|
||||||
|
"hero_title": "Build Your Dream Website",
|
||||||
|
"hero_subtitle": "Visually design, customize, and publish beautiful, responsive websites. No code required.",
|
||||||
|
"features_title": "Powerful Features",
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"icon": "bi-grid-1x2-fill",
|
||||||
|
"title": "Drag & Drop Builder",
|
||||||
|
"description": "Easily build and customize your site with our intuitive visual editor."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "bi-palette-fill",
|
||||||
|
"title": "Beautiful Templates",
|
||||||
|
"description": "Choose from a variety of professionally designed templates to get started."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "bi-phone-fill",
|
||||||
|
"title": "Fully Responsive",
|
||||||
|
"description": "Your website will look stunning on any device, from desktops to smartphones."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"about_title": "About Us",
|
||||||
|
"about_text": "We are a passionate team dedicated to making web creation accessible to everyone. Our mission is to empower you to bring your ideas to life online, without needing to write a single line of code. Join us on this journey!"
|
||||||
|
}
|
||||||
184
index.php
184
index.php
@ -3,31 +3,84 @@
|
|||||||
$content_file = __DIR__ . '/db/content.json';
|
$content_file = __DIR__ . '/db/content.json';
|
||||||
|
|
||||||
// Default content
|
// Default content
|
||||||
$content = [
|
$default_content = [
|
||||||
'hero_title' => 'Build Your Dream Website',
|
'hero_title' => 'Build Your Dream Website',
|
||||||
'hero_subtitle' => 'Visually design, customize, and publish beautiful, responsive websites. No code required.'
|
'hero_subtitle' => 'Visually design, customize, and publish beautiful, responsive websites. No code required.',
|
||||||
|
'features_title' => 'Powerful Features',
|
||||||
|
'features' => [
|
||||||
|
[
|
||||||
|
'icon' => 'bi-grid-1x2-fill',
|
||||||
|
'title' => 'Drag & Drop Builder',
|
||||||
|
'description' => 'Easily build and customize your site with our intuitive visual editor.'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'icon' => 'bi-palette-fill',
|
||||||
|
'title' => 'Beautiful Templates',
|
||||||
|
'description' => 'Choose from a variety of professionally designed templates to get started.'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'icon' => 'bi-phone-fill',
|
||||||
|
'title' => 'Fully Responsive',
|
||||||
|
'description' => 'Your website will look stunning on any device, from desktops to smartphones.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'about_title' => 'About Us',
|
||||||
|
'about_text' => 'We are a passionate team dedicated to making web creation accessible to everyone. Our mission is to empower you to bring your ideas to life online, without needing to write a single line of code. Join us on this journey!'
|
||||||
];
|
];
|
||||||
|
|
||||||
// Handle POST request to update content
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
if (isset($_POST['hero_title']) && isset($_POST['hero_subtitle'])) {
|
|
||||||
$content['hero_title'] = htmlspecialchars($_POST['hero_title']);
|
|
||||||
$content['hero_subtitle'] = htmlspecialchars($_POST['hero_subtitle']);
|
|
||||||
file_put_contents($content_file, json_encode($content, JSON_PRETTY_PRINT));
|
|
||||||
// Redirect to avoid form resubmission
|
|
||||||
header("Location: " . $_SERVER['REQUEST_URI']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load content from JSON file if it exists
|
// Load content from JSON file if it exists
|
||||||
if (file_exists($content_file)) {
|
if (file_exists($content_file)) {
|
||||||
$json_content = file_get_contents($content_file);
|
$json_content = file_get_contents($content_file);
|
||||||
$loaded_content = json_decode($json_content, true);
|
$content = json_decode($json_content, true);
|
||||||
if ($loaded_content) {
|
// Merge with defaults to ensure all keys are present
|
||||||
$content = $loaded_content;
|
$content = array_merge($default_content, $content);
|
||||||
}
|
} else {
|
||||||
|
$content = $default_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle POST request to update content
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
// Update Hero
|
||||||
|
if (isset($_POST['hero_title'])) {
|
||||||
|
$content['hero_title'] = htmlspecialchars($_POST['hero_title']);
|
||||||
|
}
|
||||||
|
if (isset($_POST['hero_subtitle'])) {
|
||||||
|
$content['hero_subtitle'] = htmlspecialchars($_POST['hero_subtitle']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update About
|
||||||
|
if (isset($_POST['about_title'])) {
|
||||||
|
$content['about_title'] = htmlspecialchars($_POST['about_title']);
|
||||||
|
}
|
||||||
|
if (isset($_POST['about_text'])) {
|
||||||
|
$content['about_text'] = htmlspecialchars($_POST['about_text']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Features Title
|
||||||
|
if (isset($_POST['features_title'])) {
|
||||||
|
$content['features_title'] = htmlspecialchars($_POST['features_title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Features
|
||||||
|
if (isset($_POST['features']) && is_array($_POST['features'])) {
|
||||||
|
$updated_features = [];
|
||||||
|
foreach ($_POST['features'] as $feature_data) {
|
||||||
|
$updated_features[] = [
|
||||||
|
'icon' => htmlspecialchars($feature_data['icon']),
|
||||||
|
'title' => htmlspecialchars($feature_data['title']),
|
||||||
|
'description' => htmlspecialchars($feature_data['description'])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$content['features'] = $updated_features;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($content_file, json_encode($content, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
// Redirect to avoid form resubmission
|
||||||
|
header("Location: " . $_SERVER['REQUEST_URI']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -73,6 +126,38 @@ if (file_exists($content_file)) {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Features Section -->
|
||||||
|
<section id="features" class="py-5">
|
||||||
|
<div class="container">
|
||||||
|
<div class="text-center mb-5">
|
||||||
|
<h2 class="display-5 fw-bold"><?php echo htmlspecialchars($content['features_title']); ?></h2>
|
||||||
|
</div>
|
||||||
|
<div class="row g-4">
|
||||||
|
<?php foreach ($content['features'] as $feature): ?>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="text-center p-4">
|
||||||
|
<i class="<?php echo htmlspecialchars($feature['icon']); ?> gradient-text" style="font-size: 3rem;"></i>
|
||||||
|
<h4 class="fw-bold my-3"><?php echo htmlspecialchars($feature['title']); ?></h4>
|
||||||
|
<p class="text-muted"><?php echo htmlspecialchars($feature['description']); ?></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- About Section -->
|
||||||
|
<section id="about" class="py-5 bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-8 text-center">
|
||||||
|
<h2 class="display-5 fw-bold"><?php echo htmlspecialchars($content['about_title']); ?></h2>
|
||||||
|
<p class="lead my-4"><?php echo htmlspecialchars($content['about_text']); ?></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Editor Section -->
|
<!-- Editor Section -->
|
||||||
<section class="editor-section">
|
<section class="editor-section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -80,18 +165,59 @@ if (file_exists($content_file)) {
|
|||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
<div class="card p-4 p-md-5">
|
<div class="card p-4 p-md-5">
|
||||||
<h2 class="text-center mb-4"><i class="bi bi-pencil-square me-2"></i>Live Editor</h2>
|
<h2 class="text-center mb-4"><i class="bi bi-pencil-square me-2"></i>Live Editor</h2>
|
||||||
<p class="text-center text-muted mb-4">Change the text in the hero section above.</p>
|
<p class="text-center text-muted mb-4">Change the text in the sections above.</p>
|
||||||
<form method="POST" action="index.php">
|
<form method="POST" action="index.php">
|
||||||
<div class="mb-3">
|
<fieldset class="mb-4">
|
||||||
<label for="hero_title" class="form-label">Hero Title</label>
|
<legend class="h5">Hero Section</legend>
|
||||||
<input type="text" class="form-control form-control-lg" id="hero_title" name="hero_title" value="<?php echo htmlspecialchars($content['hero_title']); ?>">
|
<div class="mb-3">
|
||||||
</div>
|
<label for="hero_title" class="form-label">Title</label>
|
||||||
<div class="mb-3">
|
<input type="text" class="form-control form-control-lg" id="hero_title" name="hero_title" value="<?php echo htmlspecialchars($content['hero_title']); ?>">
|
||||||
<label for="hero_subtitle" class="form-label">Hero Subtitle</label>
|
</div>
|
||||||
<textarea class="form-control" id="hero_subtitle" name="hero_subtitle" rows="3"><?php echo htmlspecialchars($content['hero_subtitle']); ?></textarea>
|
<div class="mb-3">
|
||||||
</div>
|
<label for="hero_subtitle" class="form-label">Subtitle</label>
|
||||||
|
<textarea class="form-control" id="hero_subtitle" name="hero_subtitle" rows="3"><?php echo htmlspecialchars($content['hero_subtitle']); ?></textarea>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="mb-4">
|
||||||
|
<legend class="h5">Features Section</legend>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="features_title" class="form-label">Section Title</label>
|
||||||
|
<input type="text" class="form-control" id="features_title" name="features_title" value="<?php echo htmlspecialchars($content['features_title']); ?>">
|
||||||
|
</div>
|
||||||
|
<?php foreach ($content['features'] as $index => $feature): ?>
|
||||||
|
<div class="mb-3 border-top pt-3">
|
||||||
|
<label class="form-label fw-bold">Feature <?php echo $index + 1; ?></label>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label for="feature_icon_<?php echo $index; ?>" class="form-label small">Icon (Bootstrap Icon Class)</label>
|
||||||
|
<input type="text" class="form-control" id="feature_icon_<?php echo $index; ?>" name="features[<?php echo $index; ?>][icon]" value="<?php echo htmlspecialchars($feature['icon']); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label for="feature_title_<?php echo $index; ?>" class="form-label small">Title</label>
|
||||||
|
<input type="text" class="form-control" id="feature_title_<?php echo $index; ?>" name="features[<?php echo $index; ?>][title]" value="<?php echo htmlspecialchars($feature['title']); ?>">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="feature_description_<?php echo $index; ?>" class="form-label small">Description</label>
|
||||||
|
<textarea class="form-control" id="feature_description_<?php echo $index; ?>" name="features[<?php echo $index; ?>][description]" rows="2"><?php echo htmlspecialchars($feature['description']); ?></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="mb-4">
|
||||||
|
<legend class="h5">About Section</legend>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="about_title" class="form-label">Title</label>
|
||||||
|
<input type="text" class="form-control" id="about_title" name="about_title" value="<?php echo htmlspecialchars($content['about_title']); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="about_text" class="form-label">Text</label>
|
||||||
|
<textarea class="form-control" id="about_text" name="about_text" rows="4"><?php echo htmlspecialchars($content['about_text']); ?></textarea>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<div class="d-grid">
|
<div class="d-grid">
|
||||||
<button type="submit" class="btn btn-primary btn-lg">Update Content</button>
|
<button type="submit" class="btn btn-primary btn-lg">Update All Content</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -115,4 +241,4 @@ if (file_exists($content_file)) {
|
|||||||
<!-- Custom JS -->
|
<!-- Custom JS -->
|
||||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user