diff --git a/db/content.json b/db/content.json index edf30d8..9fa0557 100644 --- a/db/content.json +++ b/db/content.json @@ -1 +1,24 @@ -{"hero_title": "Build Your Dream Website", "hero_subtitle": "Visually design, customize, and publish beautiful, responsive websites. No code required."} \ No newline at end of file +{ + "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!" +} \ No newline at end of file diff --git a/index.php b/index.php index c06e76c..37e25cc 100644 --- a/index.php +++ b/index.php @@ -3,31 +3,84 @@ $content_file = __DIR__ . '/db/content.json'; // Default content -$content = [ +$default_content = [ '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 if (file_exists($content_file)) { $json_content = file_get_contents($content_file); - $loaded_content = json_decode($json_content, true); - if ($loaded_content) { - $content = $loaded_content; - } + $content = json_decode($json_content, true); + // Merge with defaults to ensure all keys are present + $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; +} + ?> @@ -73,6 +126,38 @@ if (file_exists($content_file)) { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -80,18 +165,59 @@ if (file_exists($content_file)) { Live Editor - Change the text in the hero section above. + Change the text in the sections above. - - Hero Title - - - - Hero Subtitle - - + + Hero Section + + Title + + + + Subtitle + + + + + + Features Section + + Section Title + + + $feature): ?> + + Feature + + Icon (Bootstrap Icon Class) + + + + Title + + + + Description + + + + + + + + About Section + + Title + + + + Text + + + + - Update Content + Update All Content @@ -115,4 +241,4 @@ if (file_exists($content_file)) { -
Change the text in the hero section above.
Change the text in the sections above.