HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [357]
9. Test the image by saving the image in XCF format and a Web-friendly format (like PNG), build a simple page using the image as a background, and load the page into your browser to ensure it tiles the way you expect.
Figure 4-12 shows a sample page containing my tiled image as the background.
Figure 4-12: This page features my new tiled background.
Chapter 5: Taking Control of Content
In This Chapter
Approximating CMS with server-side includes (SSI)
Reviewing client-side includes using AJAX
Using PHP includes to build a basic CMS-style system
Building a data-based CMS
Creating a form for modifying content
Commercial sites today combine many skills and tools: XHTML, CSS, JavaScript, AJAX, databases, and PHP. This book covers many of these techniques. In this chapter you combine all these techniques to build your own content management systems. Some are very simple to build, and some are quite sophisticated.
Building a “Poor Man’s CMS” with Your Own Code
The benefits of using a CMS are very real, but you may not want to make the commitment to a full-blown CMS. For one thing, you have to learn each CMS’s particular way of doing things, and most CMSs force you into a particular mindset. For example, you think differently about pages in Drupal than you do in Website Baker (both described in Chapter 3 of this minibook). You can still get some of the benefits of a CMS with some simpler development tricks, as described in the following sections.
The examples in this chapter build on information from throughout the entire book. All of the CMSs (and pseudo-CMSs) built in this chapter use the design developed in Chapter 2 of this minibook.
Using Server-Side Includes (SSIs)
Web developers have long used the simple SSI (Server-Side Include) trick as a quick and easy way to manage content. It involves breaking the code into smaller code segments and a framework that can be copied. For example, Figure 5-1 shows a variation of the Web site developed in Chapter 2 of this minibook.
Figure 5-1: This Web page appears to be a standard page.
Even if you view the source code in the browser, you don’t find anything unusual about the page.
However, if you look at the code in a text editor, you find some interesting discoveries:
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
type = ”text/css”
href = ”csStd.css” />
Some interesting things are happening in this code snippet:
♦ The page has no content! All the actual content (the menus and the phony news stories) are gone. This page, which contains only structural information, is the heart of any kind of CSS — the structure is divorced from the content.
♦ A funky new tag is in place of the content. In each place that you expect to see text, you see an directive, instead. This special instruction tells the server to go find the specified file and put it here.
♦ The filename is unusual. The server doesn’t normally look for include tags (because most pages don’t have them). Typically, you have to save the file with the special extension .shtml to request that the server look for include directives and perform