Saturday, June 6, 2009

PHP - .NET Master Page simulator

ASP.NET has really got something with their Master pages. Oh they're just so great, and oh they're just so easy, and oh they're just so easy to use. Well, let me tell you something:
PHP has ways, lots of ways. One such way that totally kicks is kinda like a reverse 'include' file request. Instead of asking PHP to get the info from another page ( as you would do with 'include' ) , you are telling PHP to post all the markup from the current page to another PHP page. And, the best part is, it is really really simple.

1. cut down on the number of server page requests
2. have a single page that contains all your css and functions.
3. have 90%+ of your object position style on one page.
4. restoring your site's style from a backup is greatly simplified (one file backup )
5. adding additional content pages to the site is very easy.

mypage.php ( The content of your Master Page's Content Div area goes here )

<?php ob_start();?>
<em>Put all your content, markup, javascript, php, and etc here.</em>
$pagemaincontent = ob_get_contents();
$pagetitle = "Page Specific Title Text";

masterpage.php ( all your headers, footers, style, functions, etc. go here )

<title><?php echo $pagemaincontent; > </title>
</head> <body>
<div class='myclass' >
<?php echo $pagemaincontent; ?>



No comments: