What's a good way to seperate the background code from the HTML displaying code?

Clissesah

New Member
Here's a rough picture of how I how I have my files and what they do.index.php at the start displays the beginning HTML tags and includes header.php (a div of links), and at the very end includes footer.php which displays the end HTML tags.In between this, index.php takes all user input from GET parameters, POST forms, etc and gets data from the database (functions.php and mysql_functions.php). To display the body content it includes a PHP template file based on whatever page the user requested, e.g: index.php?p=page1 includes template_page1.php.The information to be displayed in the template file is stored in an array instead of just plain variables, so in the template I then have what looks like this:\[code\]<title><?php echo $content['page_title']; ?></title>\[/code\]and\[code\]<div> <?php foreach($name as $content['names']){ echo '<p>'.$name.'</p>'; } ?></div>\[/code\]There is no real heavy code in the template files, only loops and basic if statements. The heavy stuff is done in index.php and the functions files.Sometimes I feel though like it might be hacky and messy and not a good way of doing things. I looked at a template system (code igniter) the other day and it seems to be complex with so many different files to change just to display some content.Could I just have some criticisms and some pros/cons of the way I'm doing it and some ideas of how I could better do it?
 
Back
Top