Web DevCenter
oreilly.comSafari Books Online.Conferences.
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA

Sponsored Developer Resources

Web Columns
Adobe GoLive
Essential JavaScript

Web Topics
All Articles
Scripting Languages

Atom 1.0 Feed RSS 1.0 Feed RSS 2.0 Feed

Learning Lab

Dreamweaver MX: The Missing Manual

Getting Dreamweaver MX Up to Speed with PHP

by David Sawyer McFarland, author of Dreamweaver MX: The Missing Manual

Editor's note: (April 4, 2003) Dave McFarland recently discovered that he had left out some important add-ons to Dreamweaver and its PHP support. He wrote to ask whether it would be possible to either revise this article or add new text to cover these overlooked products. (Please take note of his new remarks about Interakt's extension tools at the end of this article.) What is significant about this is that Dave wrote this article almost two months ago. It bespeaks the professionalism and thoroughness of our O'Reilly authors that he would consider it important enough to correct something he wrote despite the fact it had already been published. All our O'Reilly authors have this same drive to bring to our readers every bit of information they can about the subjects they cover. Thanks Dave.

When Macromedia released Dreamweaver MX, many web developers were excited to see built-in support for PHP and MySQL. Earlier versions of the product supported ASP, ColdFusion, and JSP, but MX finally offered a simple tool for rapidly building database-driven sites using two widely-supported open source technologies: PHP and MySQL.

Unfortunately, if you've used Dreamweaver MX to build ASP, ColdFusion, or JSP sites, you'll notice that the program's PHP offerings fall a bit short. Some standard features, such as password-protecting web pages, or options for formatting dates and numbers, are missing from Dreamweaver's PHP server model. To add insult to injury, if you want to get some of that missing functionality, you'll have to shell out $99 for Macromedia's Developer Resource Kit Volume 2--an add-on that also includes new tools for other Macromedia products such as Flash, Fireworks, and ColdFusion MX.

But there's no need to settle for less, or shell out money for features that should have come with the program. With a little time spent browsing the web, you'll be able to bring Dreamweaver's PHP support up to speed, for free.

Extending Dreamweaver

Dreamweaver has always been a powerful tool for rapidly designing and building web pages. Its visual interface and substantial code-editing features have won over web developers of all levels. Dreamweaver MX also includes tools for building dynamic, database-driven web sites without in-depth programming experience. This ease of use comes from prewritten server-side scripts, called "server behaviors," which provide point- and-click access to many common programming tasks: connection scripts for accessing a database, SQL queries, loop routines for displaying multiple database records, and so on.

In designing Dreamweaver, Macromedia realized that no matter how many features it included in the program, individual developers would always require something specialized to their needs. That's why the company created an open architecture that lets anyone add new functionality using HTML, JavaScript, and XML. Most areas of the program can be customized, including menus, toolbars, commands, objects, and, yes, server behaviors.

Related Reading

Dreamweaver MX: The Missing Manual
By David Sawyer McFarland

There are legions of developers creating new "extensions" for Dreamweaver. While some extensions are commercial products, most are free, and are available at a variety of Dreamweaver-oriented web sites. The Macromedia Exchange, a clearinghouse for many extensions, is a good place to start looking for ways to expand Dreamweaver's features. You have to register at the site to access and download extensions. Once downloaded, an extension can usually be installed by double-clicking it. (If that doesn't work, you can launch the Extension Manager from within Dreamweaver by selecting the "Manage Extensions" option from the "Commands" menu.)

In this article, I'll point you in the direction of several extensions that will bring powerful and useful enhancements to Dreamweaver's PHP features.

Dreamweaver MX and PHP: The Missing Features

Dreamweaver supports several "server models," Dreamweaver's term for the server-side technologies that the program understands, such as ASP, ColdFusion MX, and PHP/MySQL. While most of the server models share the same set of server-side tools, the PHP server model lacks some important features.

PHP Server Formats

When building a dynamic page in Dreamweaver, you can create a query to retrieve information from a database, and with a simple drag-and-drop motion, add that data to your web page. In the other server models, such as ASP, you can select a piece of dynamic data that you've added to a page and format it in a variety of ways. For example, a date might be displayed as 10/1/2003 or October 1, 2003.

While Dreamweaver doesn't include server formats for PHP, you can download a free extension--PHP Server Formats--created by extension developer J. Andres Cayon. Once installed, it lets you format dynamic data using Dreamweaver's Bindings Panel: simply select the dynamic data on the page, and choose a format option from the panel. It lets you format text, currency, dates, and numbers in many different ways. For more information and to download the extension, go to www.tecnorama.org/document.php?id_doc=51, or you can get it on the Macromedia Exchange at dynamic.macromedia.com/bin/MM/exchange/extension_detail.jsp?extOid=744392.

Go To Detail Page

When building a database-driven site, it's common to build a page that lists multiple records--an index of employees, for example--and one that lists details for a particular record--Josie Smith's employee record. The second page usually retrieves an ID number, which is passed in the URL. It uses this ID to retrieve a single database record. Dreamweaver provides a simple server behavior, the Go To Detail Page, which makes the process of linking from the index page to the details page a snap, unless you're using the PHP server model.

Fortunately, developer Deng Jie has filled in the gap with the Go To Detail Page for PHP Extension. You'll find it on the Macromedia Exchange. Once installed, it can be accessed from the Server Behaviors panel, and works just like the Go To Detail page described in the Dreamweaver documentation.

User Authentication

If your site has pages that update a database--adding, changing, and deleting records--you may not want just anyone to access those. After all, it wouldn't go over well with the boss if your company's online catalog was deleted by an ignorant or malicious user. For sensitive areas of a site, such as administrative pages, password protection provides a good way to lock out intruders. While Dreamweaver doesn't provide this feature for PHP, there are several alternatives to choose from.

The PHP User Authentication Extension by FELIXONE is a free download from the Macromedia Exchange. It provides all the same functionality as the User Authentication server behaviors that ship with Dreamweaver's other server models: the ability to log users in and out, add new users to a database, and restrict access to a page. It even supports different levels of authentication so that you can create multiple types of users: admin, members, and so on.

For a more fully-featured approach, there's the commercial PHP Login Suite. This £19.99 (approximately $30 USD) extension provides many additional features, including the ability to use either cookies or session variables to track authentication. With cookie authentication, you can allow users to return to a site without having to log in again, even after they've left the site and quit their browser.

Beyond Dreamweaver MX

If you've downloaded and installed the above extensions, and brought parity to Dreamweaver's server models, you may be hungry for more. You'll find a wide range of extensions for Dreamweaver and PHP at the Macromedia Exchange, and at web sites dedicated to providing Dreamweaver extensions. Here are a few standouts:

Horizontal Looper 2 (free): Dreamweaver lets you display multiple database records using its built-in "Repeat Region" server behavior. Unfortunately, this is only useful if you want to list records on a page from top to bottom--one record per row. What if you'd like to list records across as well as down a page? For example, maybe you'd like to display three records across the page, then another row of three records, and so on, until all of the records are displayed. Horizontal Looper 2, a free extension by Tom Muck, provides just this functionality. This extension also works with ASP, JSP, and ColdFusion pages.

Recordset Navigation Suite ($35 USD): At times, you may have too many records to comfortably display on a single web page. After all, if Amazon's home page listed every book it sells, you'd be swimming in ISBN numbers. Dreamweaver can show a subset of records: 10, 20, or however many records you choose, and then provide links to navigate those records (jumping from page to page of records) using its built-in Recordset Navigation Bar. It gets the job done, but doesn't provide many options. For the ultimate in control, Tom Muck's Recordset Navigation Suite includes nearly a dozen additional behaviors for navigating records. For example, while Dreamweaver can display how many records were retrieved ("Records 1-10 of 100"), this extension can also identify how many pages of records there are ("You are currently viewing page 3 of 40 pages.").

Intellicart MX ($149 USD): Want to go into business? If you need to add shopping cart features to your web site, Intellicart MX by Tim Green may just be the ticket. This extension, which only works with the Dreamweaver's PHP server model, sports a huge list of features, including the ability to calculate shipping, store order and customer information into a database, and submit order information to PayPal for online payment processing.

If you really want power you can turn to several tools from Interakt. This long-time Dreamweaver extension development company was the first to add PHP support to Dreamweaver--even before Macromedia. If you love open source, the free PHAkt 2 is a powerful open source replacement for Macromedia's PHP/MySQL server model. It adds many of the dynamic features missing from Dreamweaver's PHP server model: user authentication, master/detail pages, and "go to detail page" server behavior. It also supports multiple database servers including PostgreSQL.

ImpAKT 2, a commercial product ($175 USD), works with either Interakt's free PHAkt PHP server model, or with Dreamweaver MX's built-in PHP/MySQL server model. In addition to behaviors offered in PHAkt 2, such as user authentication, ImpAKT 2 is a powerful toolbox of useful features: File upload and delete behaviors let you build web pages to upload files using a web browser (imagine a community scrap book with a member-created photo gallery); and simulated nested regions let you create nested lists of records. This can come in handy when you want to list records grouped by category (such as "Clothing," "Books," "Software," and so on).

Perhaps most interesting is ImpAKT's "emulated triggers" feature, which lets you trigger multiple actions based on SQL operations. For example, imagine you've deleted a record from a single table in a database. Unfortunately, if there are other records in other tables that relate to this just-deleted record, the integrity of your database is in trouble. With ImpAKT you can trigger multiple delete operations, so that when you delete one record, you can also delete the related records in the other tables of your database. Other triggers let you validate forms on submission, send email after form submission, and even create your own "custom triggers."

Out of the box, Dreamweaver MX may be a bit deficient for those interested in PHP development. But thanks to the hard work of the many extension developers, there are plenty of free and commercial add-ons available. To continue exploring ways to improve Dreamweaver's PHP support, go to the Macromedia Exchange and search on "PHP." Happy hunting.

David Sawyer McFarland is president of Sawyer McFarland Media, Inc., a Web development and training company in Portland, Oregon. He's been building websites since 1995, when he designed an online magazine for communication professionals. He wrote the bestselling Missing Manual titles on Adobe Dreamweaver, CSS, and JavaScript.

O'Reilly & Associates recently released (December 2002) Dreamweaver MX: The Missing Manual.

Return to the Web Development DevCenter.