Home arrow PHP arrow Working with CSS Styles and the Stage Pattern in PHP 5

Working with CSS Styles and the Stage Pattern in PHP 5

The stage pattern lets you build classes that can modify their behaviors according to the variations of a given programming context. If you want to learn more about it, then you should start reading this article now! Welcome to the final installment of the series that began with "Implementing the stage pattern in PHP 5." Made up of two articles, this series walks you through the application of this useful pattern, and complements the corresponding theory with illustrative code samples.

TABLE OF CONTENTS:
  1. Working with CSS Styles and the Stage Pattern in PHP 5
  2. Building a target class
  3. Defining a basic contextual class
  4. Completing the implementation of the stage pattern
By: Alejandro Gervasio
Rating: starstarstarstarstar / 4
April 25, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Stepping back quickly to the preceding tutorial of the series, you'll recall that I introduced the key concepts of the stage pattern. I also provided you with some friendly hands-on examples, aimed at demonstrating, at least basically, the functionality of this rather unusual pattern.

Speaking more specifically, in that tutorial I developed a couple of straightforward PHP classes. The first one was tasked with displaying regular DIVs on a simple web page, while the second one was capable of modifying the values assigned to the "overflow" CSS property corresponding to all these DIVs. These classes demonstrated how a particular class can change its behavior in response to the modifications introduced into its context.

Obviously, the example described above is a concise implementation of the logic followed by the stage pattern, which hopefully will help you understand more easily how it this pattern works. However, to be frank, I think that the more code samples you see covering the pattern in question, the more you'll learn about it. Therefore, in this final article of the series I'm going to provide you with another practical example of how the stage pattern works.

Essentially, what I plan to demonstrate here is how this pattern can be used to build different versions of a given web document on the fly, either for display on a typical computer monitor, or for printing. There will be a target class, responsible for defining a few CSS styles used by the pertinent web document. There will also be a contextual class to determine which of these styles will be attached to the web page in question.

Now that you know the purpose of this last tutorial of the series, let's continue learning how to implement the stage pattern with PHP 5. Let's get started now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: