Hello
I'm currently building a site for myself and in the future I would be looking at releasing it. I want to have it so it is easy to customize the template without having masses of PHP knowledge. I usually structure my sites like this:
<?php
session_start();
require ("connect.php");
require("functions.php");
include("template/header.php");
echo "This is my site";
include("template/footer.php");
?>
I have thought about storing the header.php and footer.php in a database and calling it back so it can be edited through the admin panel.
The trouble is I have many parts of code where the styling is included in the PHP, like so:
<?php
session_start();
require ("connect.php");
require("functions.php");
include("template/header.php");
if(isset($_GET['r'])){
$_SESSION['refer'] = $_GET['r'];
}
$result = mysql_query("SELECT * from gifts ORDER BY `id`");
while($list = mysql_fetch_array( $result )){
echo "<div id=\"gifts\">";
echo "<img src=\"admin/images/";
echo $list['image'];
echo "\" width=\"120px\" height=\"120px\" alt=\"GiftImage\" />";
echo "<br/>";
echo "<h5>";
echo $list['title'];
echo "</h5>";
echo "<br/>";
echo $list['description'];
echo "<br/>";
echo $list['referrals'];
echo " Referrals";
echo "<br/>";
echo "</div>";
}
include("template/footer.php");
?>
As you can see I've included a div in the while statement to style each individual item coming back from the database. I am aware this isn't the best way to style it.
I don't really want to use a template engine like smarty.
So my question is what is the best way to make a simple template editor? and what is the best way to structure my files above so there isn't design code and php code mixed up?
Thanks. 🙂