Injecting Content into a standard page layout
Posted: Sat Feb 20, 2010 11:31 am
I am working on my first website/learning php. To this project I am dedicating a significant amount of time into the framework of my site. I am a huge fan of writing things once and never reproducing the code again within the same project. With that said I have run into a bit of a problem. Basically, I have designed multiple page layouts that have a location at which I would like to insert the content of my page (one of these layouts I have included below). I know that I have the layouts broken down such that they are not much code but I hate the idea of having to surround each individual page with these layouts. I want my pages to be more along the lines of the second small section of code posted (short and neat!). But I need a way of getting the content of the page into the location it belongs within the layout page. I'm thinking that I could (although I don't know how) write my layout as a function. Then I could read the content of my page and pass it to the function to build the page. Does anyone know how I can achieve this? I am also open to better solutions as I am just trying to learn to do things right here. Thanks!
Code: Select all
<?php
include($baseDir."../../topFrame.php"); #Header
echo "<table height=\"".$mainFrameHeight."\" border=\"0\" cellspacing=\"0\">"
?>
<tr>
<td width="170">
<?php
include($baseDir."../../menu.php"); #Menu
?>
</td>
<td>
<!-- insert content of page in here -->
</td>
</tr>
</table>
<?php
include($baseDir."../../bottomFrame.php"); #Footer
?>
Code: Select all
<?php
$baseDir = "";
$mainFrameHeight = 680;
?>
<!-- Content of the page-->