'PHP Include Nav-bar For Every Page Techniques?
I'm trying to clean up my code in my php web pages by including files to consolidate each page's code's like so:
File: head.php
<!DOCTYPE html>
<html>
<head>
<title> *Dynamic Page Title* </title>
<meta name"description" "Dynamic Description">
<link href="#">
</head>
File: footer.php
<footer>
<ul>
<a href="#"><li>Home</li></a>
<a href="#"><li>Page 1</li></a>
<a href="#"><li>Page 2</li></a>
</ul>
</footer>
<script src="#">
</body>
</html>
File: navbar.php
<header class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<a href="#" class="navbar-brand"></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><i class="fa fa-bars"></i></button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="index">Home</a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">FAQ</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
</div>
</header>
File: index.php
<?php include('head.php'); ?>
<?php include('nav-bar.php'); ?>
<body>
Index Page, Home has an active class
<?php include('footer.php'); ?>
File: Page-1.php
<?php include('head.php'); ?>
<?php include('nav-bar.php'); ?>
<body>
Index Page, Page 1 in nav-bar has an active class
<?php include('footer.php'); ?>
You guys get the main idea. I would like tips on how to add active classes in different pages in the nav-bar, and how to add different titles and meta tags to each page.
Any help?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
