From 47dc23dab4408b9ee34bc8af0a5301f7976f6e52 Mon Sep 17 00:00:00 2001 From: Raghav <raghavsmart1213@gmail.com> Date: Mon, 24 Feb 2025 05:39:45 +0000 Subject: [PATCH] Header file separated and load file created --- _templates/header.php | 11 +++++++++++ index.php | 19 ++++++++----------- libs/load.php | 6 ++++++ 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 _templates/header.php create mode 100644 libs/load.php diff --git a/_templates/header.php b/_templates/header.php new file mode 100644 index 0000000..5249e39 --- /dev/null +++ b/_templates/header.php @@ -0,0 +1,11 @@ +<div class="navbar navbar-dark bg-dark shadow-sm"> + <div class="container"> + <a href="#" class="navbar-brand d-flex align-items-center"> + <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="me-2" viewBox="0 0 24 24"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg> + <strong>Album</strong> + </a> + <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation"> + <span class="navbar-toggler-icon"></span> + </button> + </div> + </div> \ No newline at end of file diff --git a/index.php b/index.php index 15271bf..a422c04 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,8 @@ +<?php +//To include load.php from libs folder +include 'libs/load.php'; +?> + <!doctype html> <html lang="en" data-bs-theme="auto"> <head><script src="/photogram-project-php/assets/js/color-modes.js"></script> @@ -170,17 +175,9 @@ </div> </div> </div> - <div class="navbar navbar-dark bg-dark shadow-sm"> - <div class="container"> - <a href="#" class="navbar-brand d-flex align-items-center"> - <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="me-2" viewBox="0 0 24 24"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg> - <strong>Album</strong> - </a> - <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation"> - <span class="navbar-toggler-icon"></span> - </button> - </div> - </div> + + <!--To load header file from template --> + <?load_template('header')?> </header> <main> diff --git a/libs/load.php b/libs/load.php new file mode 100644 index 0000000..db63d70 --- /dev/null +++ b/libs/load.php @@ -0,0 +1,6 @@ +<?php + function load_template($name){ + print("including ". __DIR__."../_templates/$name.php"); + include __DIR__. "/../_templates/$name.php"; + } +?> \ No newline at end of file -- GitLab