PHP Template System - Simplified.
1 post
Page 1 of 1
OK, so i will show you how to make a very simple template system using php.
First create your Index.php and add the basic html code to it.
Index.php
meta.php
now create a folder and name it pages
in the "pages" folder create 5 more php files
header.php
topnav.php
sidebar.php
main_index.php
footer.php
now these page can have any html, javascript, php script that you want in them.
and because they will be in the <BODY></BODY> tags. you can just use simple html tags.No <HEAD> tags.
in these pages, you can query a database to display saved data or run some ajax or what ever you want.
all you will ever need to do is add or edit the pages in the "pages" folder.
Then but copy the html from the index.php and paste it to the AboutUs.php
then create a new page in the "pages" folder called main_aboutus.php
then in the <BODY> section of the "AboutUs.php" page change
and is very flexible as well. with alittle practice and some php know how, you can make an awesome php driven website.
First create your Index.php and add the basic html code to it.
Index.php
Code: Select all
now if you wish to have the meta data in a seperate file then create a meta.php file in the "pages" folder<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" media="screen" />
<title>My Website Template System</title>
</head>
<body>
<div class="wrapper">
<div class="header"><?php include('pages/header.php'); ?></div>
<div class="topnav"><?php include('pages/topnav.php'); ?></div>
<div class="sidebar"><?php include('pages/sidebar.php'); ?></div>
<div class="main"><?php include('pages/main_index.php'); ?></div>
<div class="footer"><?php include('pages/footer.php'); ?></div>
</div>
<br />
</body>
</html>
meta.php
Code: Select all
as you can see his is just a simple html file. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
now create a folder and name it pages
in the "pages" folder create 5 more php files
header.php
topnav.php
sidebar.php
main_index.php
footer.php
now these page can have any html, javascript, php script that you want in them.
and because they will be in the <BODY></BODY> tags. you can just use simple html tags.No <HEAD> tags.
in these pages, you can query a database to display saved data or run some ajax or what ever you want.
all you will ever need to do is add or edit the pages in the "pages" folder.
Code: Select all
to make a new page that the client navigates to say "AboutUs.php"<body>
<div class="wrapper">
<div class="header"><?php include('pages/header.php'); ?></div>
<div class="topnav"><?php include('pages/topnav.php'); ?></div>
<div class="sidebar"><?php include('pages/sidebar.php'); ?></div>
<div class="main"><?php include('pages/main_index.php'); ?></div>
<div class="footer"><?php include('pages/footer.php'); ?></div>
</div>
<br />
</body>
Then but copy the html from the index.php and paste it to the AboutUs.php
then create a new page in the "pages" folder called main_aboutus.php
then in the <BODY> section of the "AboutUs.php" page change
Code: Select all
to
<div class="main"><?php include('pages/main_index.php'); ?></div>
Code: Select all
this is about the easiest way to make a template system using php.<div class="main"><?php include('pages/main_aboutus.php'); ?></div>
and is very flexible as well. with alittle practice and some php know how, you can make an awesome php driven website.
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023