How to Build an About Page on a PHP Template - dummies

By Steve Suehring, Janet Valade

Building an About page for your PHP template system is a simple matter of creating a new file, instantiating the Page class, and adding content. Follow these steps:

  1. Create a new empty file in your editor.

  2. In the file, place the following code:

    $page = new Page();
    $page->titleExtra = "About";
    print $page->getTop();
    print <<<EOF
    <div id="mainContent"> 
    <p>It's all about me.</p>
    </div> <!-- end main content →
    print $page->getBottom();
  3. Save the file as about.php in your document root.

  4. View the page in your browser by going to http://localhost/about.php.

    The page should look like the following. Notice the new title bar.


Looking at the code that you created in this exercise, notice that it’s similar to the code for the home page. The only changes are to set the titleExtra property and to change the actual HTML content of the page.

That’s the beauty of templating systems: You can now create many, many pages, quickly and easily. If you need to change something or add a new menu item, you can do so in one location and it will automatically and instantly be updated across all the pages.