PHP
  Home arrow PHP arrow Page 4 - Building a Site Engine with PHP, Part 1
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building a Site Engine with PHP, Part 1
By: James Murray
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 135
    2004-06-07


    Table of Contents:
  • Building a Site Engine with PHP, Part 1
  • First Things First
  • Better Than your Local Rental Security Officer
  • The Template Got All GUI
  • Build It and They Will Come

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building a Site Engine with PHP, Part 1 - The Template Got All GUI
    ( Page 4 of 5 )

    Even though I've loaded all my blocks into a multidimensional array with keys that correspond to the block's placement, I still need a way for the engine to know what the coordinates made up of the array keys mean. That's why we need a template system and a loading system. What this system does is it looks at the array of loaded blocks and puts them in place on the template.

    The templates are all XML based, to speed up the parse time, and with the new SimpleXML functions of PHP5, it makes it very easy to access the template data. The first thing you'd need to decide how you want the layout to look on the site. I prefer the traditional 3 column layout because it maximizes usable screen space. However it can be set up anyway you'd like, whether it's 3 columns wide, 1 column wide or even 5 columns wide.

    When the multidimensional block array is made it looks something like this:

    $blocks[1] - all the blocks in column 1

    $blocks[2] - all the blocks in column 2

    $blocks[3] - all the blocks in column 3

    And so on until the final column. As you can see, the array key determines what column of the layout the blocks will show up in. The rows are just the same as the columns, and each of those arrays are sorted in the order that the blocks with be outputted from top to bottom by specifying the row as the key. Consider the following:

    $blocks[1][1] - the top block in the first column

    $blocks[2][3] - the third block in the second column

    $blocks[3][1] - the top block in the third column

    Here's a small visual mock up of the layout that contains 3 columns 2 blocks in column 1, 2 blocks in column 2, and 1 block in column 3.

    building

    It's pretty simple and logical when you think about it.

    The template file also includes the look of the blocks, which also contains tags that will be replaced with the data that the block has such as the title and the block content. The blocks are actually each a separate file that is linked to the database by the file path then called through the plug-ins. The reason for this is because you might have a block that contains no PHP, just some HTML such as a menu block. So we replace the block template content tag with an include of the block file when the block is loaded. The blocks are by far the most confusing part of the entire site engine, but while working on it, you'll get to know and understand how it works a lot better.



     
     
    >>> More PHP Articles          >>> More By James Murray
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT