HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [340]
6. Take a vacation. You earned it!
Contemplating efficiency
When you start working with the site, you’ll probably encounter repeated code. For example, each page may have exactly the same title bar. You obviously don’t want to write exactly the same code for 100 different pages because it might change, and you don’t want to make the change in 100 different places. You have three options in this case:
♦ Use AJAX to import the repeated code. Follow the AJAX instructions in Chapter 4 of this minibook to import your header (or other repeated code).
♦ Use Server-Side Includes (SSI) to import code on the server. If your server allows it, you can use the SSI technology to import pages on the server without using a language like PHP. SSI is explained in Chapter 4 of this minibook.
♦ Build the pages with PHP. Put all segments in separate files and use a PHP script to tie them together. When you do this, you’re creating a content management system, which is the topic of Chapters 3 and 4 of this minibook.
Chapter 3: Introducing Content Management Systems
In This Chapter
Understanding the need for content management systems
Previewing typical content management systems
Installing a content management system
Adding content to a content management system
Setting up the navigation structure
Adding new types of content
Changing the appearance with themes
Building a custom theme
If you’ve ever built a large Web site, you’ll probably agree that the process can be improved. Experienced Web developers have discovered the following maxims about larger projects:
♦ Duplication should be eliminated whenever possible. If you find yourself repeatedly copying the same XHTML code, you have a potential problem. When (not if) that code needs to be changed, you have a lot of copying and pasting to do.
♦ Content should be separated from layout. You’ve already heard this statement, but it’s taken to a new level when you’re building a large site. Separating all content from the layout would be helpful so that you could create the layout only one time and change it in one location.
♦ Content is really data. At some point, the content of the Web site is really just data. It’s important data, to be sure, but the data can — and should — be separated from the layout code, and should be, if possible.
♦ Content belongs to the user. Developing a Web site for somebody can become a long-term commitment. If the client becomes dependent on the site, he frequently pesters you for changes. It would be helpful if the client could change his own content and ask you only for changes in structure or behavior.
♦ A Web site isn’t a collection of pages — it’s a framework. If you can help the client own the data, you’re more concerned with the framework for manipulating and displaying that data. It’s a good deal for you and the client.
A content management system (CMS) is designed to address exactly these issues, as this chapter will show you.
Overview of Content Management Systems
CMSs are used in many of the sites you use every day. As you examine these CMSs, you start to recognize them all over the Web. If you have your own server space, a little patience, and a little bit of knowledge, you can create your own professional-looking site using a CMS.
This list describes the general characteristics of a CMS:
♦ It’s written in a server-side language. The language is usually PHP, but CMSs are sometimes written in other languages. Stick with PHP for now because it’s described in this book, it’s easy to use, and it’s the most frequently used CMS language.
♦ All content is treated as data. Almost all the content of the CMS is stored in text files or (more commonly) a MySQL database. A CMS usually has few HTML files.
♦ The layout consists of data, too. The CSS and XHTML templates, and everything else the CMS needs, are also stored as data, in either text files or the database.
♦ All pages are created dynamically. When a user logs in to a CMS, she is normally talking to a PHP program. This