AJAX
  Home arrow AJAX arrow Create a User-Defined CSS Website with PHP
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? 
Google.com  
AJAX

Create a User-Defined CSS Website with PHP
By: Codex-M
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-10-01


    Table of Contents:
  • Create a User-Defined CSS Website with PHP
  • The Use of Sliders to Customize Colors
  • Implementation of the Slider
  • The AJAX HTML Form (Hidden)

  • 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


    Create a User-Defined CSS Website with PHP
    ( Page 1 of 4 )

    PHP as a server side scripting language can be used to customize CSS. This can make your website more readable and useful to your visitors. In this article, you'll learn what you can do to let them adjust your site so it looks good to them. This is the first part of a two-part series.

    Consider this example: you are designing a website with a black font color and white background. It seems very nice on your monitor; the problem is your readers. Some computer monitors may display your web page as extremely sharp because of the white background. Depending on the situation, some readers may be distracted while reading your piece because of it.

    This article attempts to create a sample web page where users can modify or customize the two most important CSS elements: background color and font color. To do this in real time, without affecting the page's user experience, AJAX technology will be used in accordance with PHP.

    The goal of AJAX is to communicate with the server side (PHP) without the need to reload the page. PHP will be used to receive the POST request from the browser, and then output server side commands with the customized CSS elements to the browser.

    A demo web page with these features can be found here: http://www.php-developer.org/cssajax/customcss1.php

    The Design and the CSS/Styling Aspects

    CSS/Style elements can be found in the <head> section of the web page. These HTML elements are in the format:

    <html><body>

    <head>

    <style type="text/css">

    {css elements here}

    </style>

    </head>

    </body>

    </html>

    Therefore, the PHP script that will be put out by the AJAX should be found in the <head> section for the CSS to work. Below is the style for controlling the background color and the font color of the web page:

    <style type="text/css">

    body { color: white; background: black; font-family: Verdana; }

    </style>

    By using PHP we can make the font color (in the above example it is “white” ) and the background color ( in the example it is “black”) be variables in the PHP scripts. Details of these scripts will be discussed later.

    Since AJAX will communicate with PHP and output the HTML to the body, the style should be found in the web page (see above) instead of putting the CSS elements into an external file. This will simplify the coding, although it is possible to have the script write to the CSS as a PHP file.

    For simplicity we will just put the style in the web page and not use references to external files such as this one:

    <link rel="stylesheet" type="text/css" href="test.css" />

    One of the biggest technical challenges to providing a user-defined/customizable CSS is how the colors will be generated and rendered as an HTML input. A feasible strategy is discussed next.



     
     
    >>> More AJAX Articles          >>> More By Codex-M
     

       

    AJAX ARTICLES

    - PHP AJAX Form Validation
    - Completing a User-Defined CSS Website with P...
    - Create a User-Defined CSS Website with PHP
    - Build A Better Twitter Chat Client Than Cham...
    - Using Division Equations to Make Web Forms S...
    - Using Integer Multiplication to Protect Web ...
    - Using Simple Checksums for Web Form Verifica...
    - Protecting Web Forms with AJAX
    - Using Prototip with AJAX
    - Using Prototip
    - Using the google.load() Method with Google`s...
    - How to Handle Ajax Errors
    - Uncompressing Source Files with Google`s AJA...
    - Using the jQuery Framework with Google`s Aja...
    - Using Google`s Ajax Libraries API




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek