How to Use a PHP Class in a Script
How to Retrieve Data from Specific Rows in MySQL Databases
How to Convert mysqli Functions to mysql Functions

How to Build an About Page on a PHP Template

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:

    <?php
     
    require_once("classPage.php");
     
    $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 →
     
    EOF;
     
    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.

    image0.jpg

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.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
PHP & MySQL Web Development AIO For Dummies Cheat Sheet
The Basics of Communicating with MySQL
How to Create Relationships between MySQL Tables
How to Send an SQL Server to the MySQL Server
How to Handle MySQL Errors
Advertisement

Inside Dummies.com