Dreamweaver CS3 Bible 0470122145, 9780470122143

When I received the book it was in real good condition. Only thing that didn't make it brand new was the top of the

293 11 30MB

English Pages 1212 Year 2007

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Dreamweaver CS3 Bible
 0470122145, 9780470122143

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Dreamweaver CS3 Bible ®

Joseph Lowery

Dreamweaver CS3 Bible ®

Dreamweaver CS3 Bible ®

Joseph Lowery

Dreamweaver® CS3 Bible Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com

Copyright © 2007 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-12214-3 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Library of Congress Cataloging-in-Publication Data is available from the Publisher Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Dreamweaver is a registered trademark of Adobe Systems Incorporated in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

About the Author Joseph Lowery has been writing about computers and new technology since 1981. He is the author of the previous editions of Dreamweaver Bible and Fireworks Bible as well as the recent publishing of CSS Hacks and Filters (all published by Wiley). He is also the author of Joseph Lowerys Beyond Dreamweaver, Dreamweaver MX 2004 Killer Tips (with Angela Buraglia), and Dreamweaver MX 2004 Web Application Recipes and Dreamweaver CS3 Recipes (with Eric Ott), all published by New Riders. He has also written books on HTML and using the Internet for business. His books are international bestsellers, having sold more than 400,000 copies worldwide in eleven different languages. Joe is also a consultant and trainer and has presented at Seybold in both Boston and San Francisco, Adobe conferences in the U.S. and Europe, and at ThunderLizard’s Web Design World. He is currently the Vice President of Marketing for WebAssist, the leading provider of Adobe extensions.

About the Instructional Designer One of the innovations in Dreamweaver CS3 Bible is the inclusion of Captivate simulations on the CD-ROM, one for each of the Dreamweaver Techniques in the book. All of these interactive movies were created by Mark Fletcher. Mark Fletcher has been in the I.T. industry for 17 years. He began his career as a database administrator and has been a web developer / trainer for the Virtual Training Company. Mark is involved in developing training courses on Dreamweaver amongst other Adobe Internet Products. He is a regular contributor to Adobe’s Developer Centre. Mark currently works for the Adobe Extension developer WebAssist where he spends much of his time creating instructional content created in Adobe Captivate. Mark was also the technical editor for CSS Hacks and Filters by Joseph Lowery (Wiley Publishing). Mark lives on the Northwest coast of the United Kingdom with his wife Vanessa and their two children, Joel and Lucy. Mark can be reached on his personal blog, http://macrofireball.blogspot.com/.

For Star, who always knows when to lay her head on my thigh and look up with those eloquent eyes.

Credits Executive Editor Chris Webb

Project Coordinator Bill Ramsey

Development Editors Maryann Steinhart Rosanne Koneval

Graphics and Production Specialists Sean Decker Jennifer Mayberry

Technical Editor Derren Whiteman

Media Development Project Supervisor Laura Atkinson

Production Editor Christine O’Connor

Media Development Specialist Kit Malone

Copy Editors Kim Cofer Jeri Friedman

Media Quality Assurance Angie Denny

Editorial Manager Mary Beth Wakefield

Proofreading C.M. Jones Brian H. Walls

Production Manager Tim Tate

Indexer Johnna VanHoose Dinse

Vice President and Executive Group Publisher Richard Swadley

Anniversary Logo Design Richard Pacifico

Vice President and Executive Publisher Joseph B. Wikert

Acknowledgments ..............................................................................................................................xxix Introduction........................................................................................................................................xxxi

Part I: Laying the Groundwork in Dreamweaver CS3 . . . . . . . . . 1 Chapter 1: What’s New in Dreamweaver CS3 ........................................................................................3 Chapter 2: Introducing Dreamweaver CS3 ..............................................................................................9 Chapter 3: Touring Dreamweaver ..........................................................................................................39 Chapter 4: Setting Your Preferences ......................................................................................................79 Chapter 5: Setting Up Sites and Servers ..............................................................................................117

Part II: Designing and Crafting Core Pages . . . . . . . . . . . . . . . 153 Chapter 6: Accessing the Code Directly ..............................................................................................155 Chapter 7: Building Style Sheet Web Pages ........................................................................................209 Chapter 8: Working with Text ............................................................................................................251 Chapter 9: Inserting Images ................................................................................................................301 Chapter 10: Establishing Web Links ..................................................................................................337

Part III: Adding Advanced Design Features . . . . . . . . . . . . . . . 355 Chapter 11: Working with Divs and AP Elements ..............................................................................357 Chapter 12: Using Behaviors ..............................................................................................................399 Chapter 13: Setting Up Tables ............................................................................................................443 Chapter 14: Interactive Forms ............................................................................................................485 Chapter 15: Creating Lists ..................................................................................................................519 Chapter 16: Using Frames and Framesets ..........................................................................................545 Chapter 17: Working with Timelines ..................................................................................................575 Chapter 18: Powering Ajax Pages with Spry ......................................................................................593

Part IV: Incorporating Dynamic Data . . . . . . . . . . . . . . . . . . . 635 Chapter 19: Establishing Connections and Recordsets ........................................................................637 Chapter 20: Making Data Dynamic ....................................................................................................669 Chapter 21: Managing Data ................................................................................................................691 Chapter 22: Working with Live Data ..................................................................................................713 Chapter 23: Crafting Multiple-Page Applications ................................................................................729

viii

Part V: Including Multimedia Elements . . . . . . . . . . . . . . . . . . 763 Chapter 24: Adobe Photoshop, Fireworks, and Bridge Integration ....................................................765 Chapter 25: Inserting Flash and Shockwave Elements ........................................................................793 Chapter 26: Adding Video to Your Web Page ......................................................................................821 Chapter 27: Using Audio on Your Web Page ......................................................................................847

Part VI: Enhancing Productivity and Web Site Management . . . 867 Chapter 28: Using Dreamweaver Templates ........................................................................................869 Chapter 29: Using Repeating Elements ..............................................................................................911 Chapter 30: Maximizing Browser Targeting ........................................................................................927 Chapter 31: Building Web Sites with a Team ......................................................................................943 Chapter 32: Integrating with XML and XSLT ......................................................................................985

Part VII: Extending Dreamweaver . . . . . . . . . . . . . . . . . . . . . 1009 Chapter 33: Customizing Dreamweaver ............................................................................................1011 Chapter 34: Handling Server Behaviors ............................................................................................1053

Part VIII: Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1087 Appendix A: What’s on the CD-ROM? ..............................................................................................1089

Bonus Chapters . . . . . . . . . . . . . . . . . . . . . . . . . . On the CD-ROM Bonus Chapter 1 Bonus Chapter 2 Index ................................................................................................................................................1093 End-User License Agreement ............................................................................................................1113

ix

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi

Part I: Laying the Groundwork in Dreamweaver CS3

1

Chapter 1: What’s New in Dreamweaver CS3 . . . . . . . . . . . . . . . . . 3 Web 2.0 Spoken Here ..................................................................................................................4 Adobe Connectivity ......................................................................................................................5 CSS Enhancements ......................................................................................................................6 Program-Wide Improvements ......................................................................................................7 Summary ......................................................................................................................................8

Chapter 2: Introducing Dreamweaver CS3 . . . . . . . . . . . . . . . . . . . 9 The Dynamic World of Dreamweaver ..........................................................................................9 Connecting to the world’s data ........................................................................................10 True data representation ..................................................................................................11 Integrated visual and text editors ....................................................................................11 World-class code editing ..................................................................................................12 Roundtrip HTML ............................................................................................................13 Web site maintenance tools ..............................................................................................14 Team-oriented site building ..............................................................................................15 The Dreamweaver Interface ........................................................................................................15 Easy text entry ................................................................................................................15 Drag-and-drop data fields ................................................................................................15 One-stop object modification ..........................................................................................17 Accessing and managing resources ..................................................................................17 Complete custom environment ........................................................................................17 Managing keyboard shortcuts ..........................................................................................18 Simple selection process ..................................................................................................18 Enhanced layout options ..................................................................................................18 Plugin media preview ......................................................................................................19 Extended find and replace ................................................................................................20 Up-to-Date Code Standards ........................................................................................................20 Cutting-edge CSS support ................................................................................................20 Addressing accessibility ....................................................................................................21 Straightforward text and graphics support ......................................................................21 Enhanced table capabilities ..............................................................................................22 Easy form entry ................................................................................................................23 Click-and-drag frame setup ..............................................................................................23 Multimedia enhancements ..............................................................................................24

xi

Contents

Next-Generation Features ..........................................................................................................24 Ajax spoken here ............................................................................................................24 Dynamic style updates ....................................................................................................24 Photoshop, Flash, and Fireworks integration ..................................................................25 Server-side behaviors ......................................................................................................26 XML and XSLT integration ..............................................................................................27 CSS layout control ..........................................................................................................27 JavaScript behaviors ........................................................................................................28 Program Extensibility ................................................................................................................29 Objects and behaviors ......................................................................................................29 Server Behavior Builder ....................................................................................................30 Commands and floating panels ........................................................................................30 Adjustable Insert bars ......................................................................................................31 Custom tags, translators, and Property inspectors ............................................................31 Automation Enhancements ........................................................................................................31 Rapid application development with Application objects ................................................31 Importing Office documents ............................................................................................32 Reference panel ................................................................................................................33 History panel ..................................................................................................................33 Site Management Tools ..............................................................................................................33 Object libraries ................................................................................................................33 Supercharged templates ..................................................................................................34 Browser targeting ............................................................................................................35 Converting Web pages ....................................................................................................36 Verifying links ..................................................................................................................36 FTP publishing ................................................................................................................36 Site Map ..........................................................................................................................36 File Check In/Check Out ................................................................................................37 Summary ....................................................................................................................................38

Chapter 3: Touring Dreamweaver . . . . . . . . . . . . . . . . . . . . . . . . 39 Choosing a Workspace Layout ....................................................................................................39 Viewing the Document Window..................................................................................................42 Switching views in the Document window........................................................................43 Working with the status bar ..............................................................................................44 Accessing the Toolbars ................................................................................................................50 The Document toolbar ......................................................................................................50 The Standard toolbar ........................................................................................................54 The Style Rendering toolbar ..............................................................................................55 The Coding toolbar ..........................................................................................................55 The Live Data toolbar........................................................................................................57 Selecting from the Insert Bar........................................................................................................58 Common objects ..............................................................................................................60 Layout objects ..................................................................................................................61 Forms objects....................................................................................................................61 Data objects ......................................................................................................................62 Spry objects ......................................................................................................................62 Text objects ......................................................................................................................64 Favorites ..........................................................................................................................65

xii

Contents

ASP objects ......................................................................................................................66 ASP.NET objects................................................................................................................66 CFML objects....................................................................................................................66 JSP objects ........................................................................................................................67 PHP objects ......................................................................................................................67 XSLT objects ....................................................................................................................67 Getting the Most Out of the Property Inspector ..........................................................................67 Manipulating the Property inspector ................................................................................67 Property inspector elements ..............................................................................................68 Customizing Your Workspace with Dockable Panels ..................................................................70 Hiding and showing panels ..............................................................................................73 Customizing panel groups ................................................................................................74 Accessing the Menus ..................................................................................................................76 Summary ....................................................................................................................................77

Chapter 4: Setting Your Preferences . . . . . . . . . . . . . . . . . . . . . . 79 Customizing Your Environment ................................................................................................79 General preferences ..........................................................................................................79 Preferences for invisible elements ....................................................................................85 Highlighting preferences ..................................................................................................86 Status Bar preferences ......................................................................................................88 File Types / Editors preferences ........................................................................................89 Copy/Paste preferences ....................................................................................................92 New Document preferences ............................................................................................93 Adjusting Advanced Features ....................................................................................................94 Accessibility preferences ..................................................................................................94 Layout Mode preferences ................................................................................................95 AP Elements preferences ..................................................................................................97 CSS Styles preferences ......................................................................................................99 Making Online Connections ....................................................................................................100 Site preferences ..............................................................................................................100 Preview In Browser preferences ......................................................................................102 Customizing Your Code ..........................................................................................................104 Fonts preferences ..........................................................................................................104 Code Hints preferences ..................................................................................................105 Code Rewriting preferences ............................................................................................106 Code Coloring preferences ............................................................................................109 Code Format preferences ..............................................................................................110 Validator preferences ......................................................................................................113 Summary ..................................................................................................................................115

Chapter 5: Setting Up Sites and Servers . . . . . . . . . . . . . . . . . . . 117 Planning Your Site ....................................................................................................................118 Primary considerations ..................................................................................................118 Design options ..............................................................................................................119 Mapping Dynamic Pages for Web Applications ........................................................................122 Defining a Site ..........................................................................................................................123 Using the Site Definition Wizard ....................................................................................123 Using Advanced mode ..................................................................................................127

xiii

Contents

Establishing local connections ........................................................................................128 Specifying the remote site ..............................................................................................129 Adding testing server details ..........................................................................................132 Cloaking Site Folders ..............................................................................................................133 Managing Site Info ..................................................................................................................134 Working Directly with Servers ..................................................................................................135 Establishing a siteless server connection ........................................................................135 Accessing server files ......................................................................................................138 Creating and Saving New Pages ................................................................................................139 Starting Dreamweaver ....................................................................................................140 Opening existing files ....................................................................................................140 Opening a new file ........................................................................................................140 Saving your file ..............................................................................................................142 Saving to remote servers ................................................................................................142 Closing the file ..............................................................................................................143 Quitting the program ....................................................................................................143 Creating New Documents ........................................................................................................143 Using the New Document dialog box ............................................................................144 Creating a new default document ..................................................................................146 Previewing Your Web Pages ......................................................................................................146 Putting Your Pages Online ........................................................................................................148 Transferring with FTP ....................................................................................................148 Using the FTP Log panel ................................................................................................150 Summary ..................................................................................................................................151

Part II: Designing and Crafting Core Pages

153

Chapter 6: Accessing the Code Directly . . . . . . . . . . . . . . . . . . . 155 The Structure of a Web Page ....................................................................................................156 Expanding into XHTML ..........................................................................................................157 doctype and doctype Switching ................................................................................................158 Defining Elements ........................................................................................................159 Establishing Page Properties ..........................................................................................159 Understanding and other tags ..............................................................164 Adding to the ..............................................................................................................172 Logical styles ..................................................................................................................172 Physical styles ................................................................................................................173 Working with Code View and the Code Inspector ....................................................................173 Enabling Code view options ..........................................................................................175 Printing code ................................................................................................................176 Using the Coding Toolbar ........................................................................................................177 Code collapse ................................................................................................................177 Code selection and highlight ..........................................................................................180 Commenting code ..........................................................................................................180 Manipulating CSS ..........................................................................................................180 Other Coding toolbar functions ....................................................................................181

xiv

Contents

Enhancing Code Authoring Productivity ..................................................................................182 Code Hints and Tag Completion ....................................................................................182 Modifying blocks of code ..............................................................................................184 Inserting code with the Tag Chooser ..............................................................................186 Adding Code through the Snippets Panel ................................................................................187 Using the Reference Panel ........................................................................................................189 Modifying Code with the Tag Inspector ....................................................................................192 Rapid Tag Modification with the Quick Tag Editor ..................................................................193 Insert HTML mode ........................................................................................................194 Wrap Tag mode ..............................................................................................................195 Edit Tag mode ................................................................................................................197 Adding Java Applets ................................................................................................................198 Adding JavaScript and VBScript ..............................................................................................200 Inserting JavaScript and VBScript ..................................................................................200 Editing JavaScript and VBScript ....................................................................................202 Validating Your Page ................................................................................................................203 Inserting Symbols and Special Characters ................................................................................204 Named characters ..........................................................................................................205 Decimal characters and UTF-8 encoding ........................................................................205 Using the Character objects ............................................................................................206 Summary ..................................................................................................................................207

Chapter 7: Building Style Sheet Web Pages

. . . . . . . . . . . . . . . . . 209

Understanding Cascading Style Sheets ....................................................................................210 Grouping properties ......................................................................................................210 Inheritance of properties ................................................................................................211 Cascading characteristics ................................................................................................211 Defining new class and ID selectors for extended design control ....................................212 Specificity ......................................................................................................................213 How styles are applied ..................................................................................................213 Working with the CSS Styles Panel ..........................................................................................215 All mode ........................................................................................................................215 Current mode ................................................................................................................217 Creating and Applying a Style Sheet in Dreamweaver ..............................................................219 Automatically created styles ..........................................................................................219 Applying styles through the Property inspector ..............................................................221 Attaching an external style sheet ....................................................................................221 Applying, changing, and removing a style ......................................................................223 Defining new rules ........................................................................................................226 Editing and managing style sheets ..................................................................................229 Debugging your applied CSS ........................................................................................233 Styles and Their Attributes ......................................................................................................236 Type options ..................................................................................................................236 Background options ......................................................................................................237 Block options ................................................................................................................239 Box options ....................................................................................................................240 Border options ..............................................................................................................241 List options ....................................................................................................................242

xv

Contents

Positioning options ........................................................................................................243 Extensions options ........................................................................................................245 Design Time Style Sheets ..........................................................................................................248 Summary ..................................................................................................................................249

Chapter 8: Working with Text . . . . . . . . . . . . . . . . . . . . . . . . . 251 Starting with Headings ............................................................................................................251 Working with Paragraphs ........................................................................................................253 Inserting text ..................................................................................................................255 Cutting, copying, and pasting ........................................................................................255 Using drag-and-drop ......................................................................................................256 Inserting text from other text applications ......................................................................256 Copying and pasting code ..............................................................................................257 Undo, redo, and the History panel ................................................................................257 Checking Your Spelling ............................................................................................................259 Using Find and Replace ............................................................................................................260 Finding on the visual page ............................................................................................260 Searching the code ........................................................................................................264 Concentrating your search with regular expressions ......................................................269 Controlling Whitespace ............................................................................................................273 Indenting text ................................................................................................................273 Working with preformatted text ....................................................................................274 The
tag ..................................................................................................................274 Working with Microsoft Office Documents ..............................................................................276 Copying and pasting Office content ..............................................................................276 Importing Office documents ..........................................................................................277 Dragging and dropping Word and Excel files ................................................................278 Importing Word HTML ..................................................................................................278 Styling Your Text ......................................................................................................................281 Depicting various styles ................................................................................................281 Using the tag ................................................................................................284 Adding abbreviations and acronyms ..............................................................................284 Modifying Text Format ............................................................................................................285 Adjusting font size ........................................................................................................285 Absolute size ..................................................................................................................288 Relative size ..................................................................................................................288 Adding font color ..........................................................................................................289 Assigning a specific font ................................................................................................292 Aligning text ..................................................................................................................295 Indenting entire paragraphs ..........................................................................................296 Incorporating Dates ..................................................................................................................297 Commenting Your Code ..........................................................................................................298 Summary ..................................................................................................................................300

Chapter 9: Inserting Images . . . . . . . . . . . . . . . . . . . . . . . . . . 301 Web Graphic Formats ..............................................................................................................301 GIF ................................................................................................................................302 JPEG ..............................................................................................................................303 PNG ..............................................................................................................................304

xvi

Contents

Using Inline Images ..................................................................................................................304 Inserting images ............................................................................................................304 Dragging images from the Assets panel ..........................................................................308 Optimizing and altering images ....................................................................................311 Modifying image attributes ............................................................................................318 Working with alignment options ....................................................................................321 Adding Background Images ......................................................................................................324 Dividing the Web Page with Horizontal Rules ..........................................................................327 Applying Simple Web Animation ............................................................................................328 Including Banner Ads ..............................................................................................................329 Inserting Rollover Images ........................................................................................................331 Adding a Navigation Bar ..........................................................................................................333 Summary ..................................................................................................................................336

Chapter 10: Establishing Web Links . . . . . . . . . . . . . . . . . . . . . . 337 Understanding URLs ................................................................................................................337 Surfing the Web with Hypertext ..............................................................................................339 Eliminating underlines from links ..................................................................................341 Inserting URLs from the Assets panel ............................................................................342 Pointing to a file ............................................................................................................344 Addressing types ............................................................................................................345 Checking links ..............................................................................................................345 Adding an Email Link ..............................................................................................................347 Navigating with Anchors ..........................................................................................................348 Moving within the same document ................................................................................349 Using named anchors in a different page ........................................................................350 Creating null links ........................................................................................................351 Targeting Your Links ................................................................................................................352 Summary ..................................................................................................................................353

Part III: Adding Advanced Design Features

355

Chapter 11: Working with Divs and AP Elements . . . . . . . . . . . . . . 357 Divs and AP Elements 101 ......................................................................................................357 Placing Tags ....................................................................................................................360 Defining a CSS rule for a tag ................................................................................360 Inserting the tag ..................................................................................................361 Visualizing tags ....................................................................................................363 Creating AP Elements with Dreamweaver ................................................................................368 Inserting an AP element object ......................................................................................368 Using the Insert ➪ Layout Objects ➪ AP Div option ......................................................370 Setting default characteristics of an AP element ..............................................................370 Choosing relative instead of absolute positioning ..........................................................372 Modifying an AP Element ........................................................................................................373 Selecting an AP element ................................................................................................373 Resizing an AP element ..................................................................................................374 Moving an AP element ..................................................................................................374

xvii

Contents

Using the CSS-P Property inspector ..............................................................................374 The AP Elements panel ..................................................................................................381 Aligning AP elements ....................................................................................................383 Adding elements to an AP element ................................................................................389 Forms and AP elements ................................................................................................390 Creating Your Page Design with AP Elements ..........................................................................390 Using the Tracing Image ................................................................................................391 Preventing overlaps ........................................................................................................392 Activating AP Elements with Behaviors ....................................................................................392 Drag AP Element ............................................................................................................393 Set Text of Container ......................................................................................................394 Show-Hide Elements ......................................................................................................396 Creating a Loading AP Element ................................................................................................397 Summary ..................................................................................................................................397

Chapter 12: Using Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . 399 Understanding Behaviors, Events, and Actions ........................................................................399 Attaching a Behavior ................................................................................................................400 Using the Behaviors panel ..............................................................................................401 Adding a behavior ..........................................................................................................402 Managing events ............................................................................................................405 Standard actions ............................................................................................................408 New Adobe effects in Dreamweaver CS3 ........................................................................426 Deprecated behaviors ....................................................................................................432 Installing, Managing, and Modifying Behaviors ........................................................................437 Altering the parameters of a behavior ............................................................................438 Sequencing behaviors ....................................................................................................440 Deleting behaviors ........................................................................................................440 Summary ..................................................................................................................................441

Chapter 13: Setting Up Tables . . . . . . . . . . . . . . . . . . . . . . . . . 443 HTML Table Fundamentals ......................................................................................................444 Rows ..............................................................................................................................445 Cells ..............................................................................................................................445 Column and row headings ............................................................................................446 Inserting Tables in Dreamweaver ..............................................................................................446 Modifying Tables ......................................................................................................................451 Selecting table elements ................................................................................................451 Editing a table’s contents ................................................................................................454 Working with table properties ........................................................................................458 Setting cell, column, and row properties ........................................................................468 Sorting Tables ..........................................................................................................................470 Importing Tabular Data ............................................................................................................472 Designing with Layout Mode ....................................................................................................473 Drawing cells and tables ................................................................................................475 Modifying layouts ..........................................................................................................479 Summary ..................................................................................................................................483

xviii

Contents

Chapter 14: Interactive Forms

. . . . . . . . . . . . . . . . . . . . . . . . 485

How HTML Forms Work ........................................................................................................485 Inserting a Form in Dreamweaver ............................................................................................487 Using Text Fields ......................................................................................................................489 Inserting text fields ........................................................................................................489 Creating password fields ................................................................................................489 Inserting multiline text areas ..........................................................................................490 Providing Checkboxes and Radio Buttons ................................................................................493 Checkboxes ..................................................................................................................494 Radio buttons ................................................................................................................494 Creating Form Lists and Menus ................................................................................................498 Drop-down menus ........................................................................................................498 Menu values ..................................................................................................................499 Scrolling lists ..................................................................................................................500 Navigating with a Jump Menu ..................................................................................................504 Modifying a jump menu ................................................................................................506 Activating Go buttons ....................................................................................................507 Activating Your Form with Buttons ..........................................................................................508 Submit, Reset, and Command buttons ..........................................................................508 Graphical buttons ..........................................................................................................509 Using Hidden and File Fields ..................................................................................................510 The hidden input type ..................................................................................................510 The file input type ........................................................................................................511 Improving Accessibility ............................................................................................................511 Styling Forms with CSS ............................................................................................................512 Encompassing the form ..................................................................................................513 Altering input fields ......................................................................................................514 Distinguishing lists and menus ......................................................................................515 Changing labels and legends ..........................................................................................515 Highlighting focus ........................................................................................................516 Summary ..................................................................................................................................517

Chapter 15: Creating Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 Creating Unordered (Bulleted) Lists ........................................................................................519 Editing unordered lists ..................................................................................................520 List tags ..........................................................................................................................521 Using other bullet symbols ............................................................................................523 Styling lists with CSS ....................................................................................................524 Mastering Ordered (Numbered) Lists ......................................................................................525 Editing ordered lists ......................................................................................................526 Using other numbering styles ........................................................................................528 Creating Navigation Buttons from Lists ....................................................................................529 Step 1: Preparing background graphics ..........................................................................530 Step 2: Creating the list and containing ................................................................531 Step 3: Building the CSS styles ......................................................................................533 Step 4: Applying the CSS ..............................................................................................538 Making Definition Lists ............................................................................................................538 Using Nested Lists ....................................................................................................................541

xix

Contents

Accessing Special List Types ....................................................................................................543 Menu lists ......................................................................................................................543 Directory lists ................................................................................................................544 Summary ..................................................................................................................................544

Chapter 16: Using Frames and Framesets . . . . . . . . . . . . . . . . . . 545 Frames and Framesets: The Basics ............................................................................................546 Columns and rows ........................................................................................................546 Sizing frames ..................................................................................................................546 Creating a Frameset and Frames ..............................................................................................547 Creating a new frameset file ..........................................................................................547 Hand-coding framesets ..................................................................................................549 Creating a frameset visually ............................................................................................549 Creating framesets quickly with frame objects ................................................................550 Adding More Frames ................................................................................................................553 Using the menus ............................................................................................................553 Using the Mouse ............................................................................................................553 Selecting, Saving, and Closing Framesets ..................................................................................555 Selecting framesets and frames ......................................................................................555 Saving framesets and frames ..........................................................................................556 Closing framesets ..........................................................................................................556 Working with the Frameset Property Inspector ........................................................................558 Resizing frames in a frameset ........................................................................................558 Manipulating frameset borders ......................................................................................560 Modifying a Frame ..................................................................................................................560 Page properties ..............................................................................................................561 Working with the Frame Property inspector ..................................................................562 Modifying content ..........................................................................................................565 Deleting frames ..............................................................................................................565 Targeting Frame Content ..........................................................................................................565 Targeting sections of your frameset ................................................................................566 Targeting specific frames in your frameset ......................................................................567 Updating two or more frames at once ............................................................................567 Handling Frameless Browsers ..................................................................................................569 Investigating Iframes ................................................................................................................570 Summary ..................................................................................................................................572

Chapter 17: Working with Timelines . . . . . . . . . . . . . . . . . . . . . 575 Into the Fourth Dimension with Timelines ..............................................................................575 A few ground rules ........................................................................................................576 Creating Animations with Timelines ........................................................................................577 Adding AP Elements and Images to the Timelines Panel ..........................................................577 Modifying a Timeline ..............................................................................................................580 Altering the animation bars ............................................................................................580 Using the Timeline controls ..........................................................................................581 Adding keyframes ..........................................................................................................584 Removing timeline elements ..........................................................................................585 Changing animation speed ............................................................................................586 Recording an AP element’s path ......................................................................................586

xx

Contents

Triggering Behaviors in Timelines ............................................................................................588 Summary ..................................................................................................................................591

Chapter 18: Powering Ajax Pages with Spry . . . . . . . . . . . . . . . . . 593 Understanding Ajax and Spry ..................................................................................................594 What is Ajax? ................................................................................................................594 What is Spry? ................................................................................................................594 Integrating XML Data with Spry ..............................................................................................596 Connecting to XML data ................................................................................................597 Defining Spry regions ....................................................................................................600 Binding data to the page ................................................................................................602 Repeating Spry regions ..................................................................................................604 Working with Spry tables ..............................................................................................607 Enhancing Your Site with Spry Widgets ..................................................................................612 Validating form fields ....................................................................................................613 Extending layout options ..............................................................................................624 Spry Effects ..............................................................................................................................632 Summary ..................................................................................................................................633

Part IV: Incorporating Dynamic Data

635

Chapter 19: Establishing Connections and Recordsets . . . . . . . . . . . 637 Data Source Basics ....................................................................................................................637 Understanding How Active Content Pages Work ......................................................................640 Opening a Connection to a Data Source ..................................................................................642 Using Data Source Names (DSN) ..................................................................................644 Specifying connection strings ........................................................................................653 PHP ..............................................................................................................................657 Managing Connections ............................................................................................................659 Extracting Recordsets ..............................................................................................................660 Building simple recordsets ............................................................................................660 Writing advanced SQL statements ..................................................................................662 Working with recordsets ................................................................................................666 Summary ..................................................................................................................................668

Chapter 20: Making Data Dynamic . . . . . . . . . . . . . . . . . . . . . . 669 Working with Dynamic Text ....................................................................................................669 Inserting dynamic text ..................................................................................................669 Viewing dynamic data ....................................................................................................671 Formatting Dynamic Data ........................................................................................................673 Data formatting ..............................................................................................................674 Editing and creating new data formats ..........................................................................681 Making Images Dynamic ..........................................................................................................683 Integrating Flash and Other Dynamic Media ............................................................................688 Summary ..................................................................................................................................690

xxi

Contents

Chapter 21: Managing Data . . . . . . . . . . . . . . . . . . . . . . . . . . 691 Displaying Data Conditionally ..................................................................................................691 Repeating data ..............................................................................................................692 Showing and hiding page elements ................................................................................697 Handling Record Navigation ....................................................................................................698 Building record navigation links ....................................................................................698 Using Application objects for record navigation ............................................................700 Tracking record status ....................................................................................................701 Navigating Recordsets with Flash Buttons ................................................................................704 Step 1: Prepare the page ................................................................................................704 Step 2: Add the Flash buttons ........................................................................................705 Step 3: Include the JavaScript functions ........................................................................707 Step 4: Insert the hidden variables ................................................................................708 Summary ..................................................................................................................................710

Chapter 22: Working with Live Data . . . . . . . . . . . . . . . . . . . . . 713 Viewing Live Data ....................................................................................................................714 How Live Data works ....................................................................................................714 Setting up for Live Data ................................................................................................714 Entering and exiting Live Data view ..............................................................................718 Making changes in Live Data ..........................................................................................718 Live Data Settings ....................................................................................................................719 Getting the query string ................................................................................................719 Posting responses with Live Data settings ......................................................................721 Previewing an Application in the Browser ................................................................................725 Using the Server Debug Panel with ColdFusion ......................................................................726 Summary ..................................................................................................................................728

Chapter 23: Crafting Multiple-Page Applications . . . . . . . . . . . . . . 729 Using the URL to Pass Parameters ............................................................................................729 Sending parameters ........................................................................................................730 Receiving parameters ....................................................................................................732 Automating Master-Detail Page production ....................................................................734 Getting Values from a Form ......................................................................................................738 Passing single values from a form ..................................................................................739 Passing multiple values from a form ..............................................................................740 Passing form and URL values to a related page ..............................................................740 Establishing Dynamic Form Elements ......................................................................................743 Text fields ......................................................................................................................743 Checkboxes ..................................................................................................................744 Radio buttons ................................................................................................................745 List/menus ....................................................................................................................746 Managing Data Sources Online ................................................................................................747 Inserting data ................................................................................................................747 Updating data ................................................................................................................750 Deleting data ..................................................................................................................752 Inserting Variables ....................................................................................................................753 Application and session variables ..................................................................................754 Request and other variables ............................................................................................754

xxii

Contents

Connecting to the Customer ....................................................................................................757 Logging in existing customers ........................................................................................757 Restricting access ..........................................................................................................758 Helping users log out ....................................................................................................760 Adding new customers ..................................................................................................761 Summary ..................................................................................................................................762

Part V: Including Multimedia Elements

763

Chapter 24: Adobe Photoshop, Fireworks, and Bridge Integration . . . . . 765 Graphics Modification Made Easy ............................................................................................766 Bringing in Photoshop Images ..................................................................................................766 Inserting Photoshop files ................................................................................................766 Copying and pasting from Photoshop ............................................................................768 Updating a Photoshop image ........................................................................................769 Integrating Fireworks ..............................................................................................................770 Optimizing an image in Fireworks ................................................................................771 Editing an image in Fireworks ........................................................................................775 Replacing an image placeholder using Fireworks ..........................................................776 Inserting Rollovers ..................................................................................................................779 Using Dreamweaver’s behaviors ....................................................................................779 Using Fireworks’ code ....................................................................................................781 Modifying sliced images ................................................................................................784 Controlling Fireworks with Dreamweaver ................................................................................785 Creating a Web photo album ........................................................................................785 Building Dreamweaver/Fireworks extensions ................................................................788 Working with Bridge ................................................................................................................790 Summary ..................................................................................................................................791

Chapter 25: Inserting Flash and Shockwave Elements . . . . . . . . . . . . 793 Director and Flash: What’s the Difference? ................................................................................794 Including Flash and Shockwave Movies in Dreamweaver Projects ............................................796 Specifying Shockwave Properties ..............................................................................................798 Additional parameters for Shockwave ............................................................................800 Automatic settings for Shockwave files ..........................................................................800 Designating Flash Attributes ....................................................................................................801 Setting Scale in Flash movies ..........................................................................................802 Additional parameters for Flash ....................................................................................802 Integrating Flash Elements ......................................................................................................803 Working with the Image Viewer ....................................................................................804 Adding other Flash elements ..........................................................................................807 Creating Flash Buttons ............................................................................................................810 Working with Flash Text ..........................................................................................................812 Configuring MIME Types ..........................................................................................................814 Managing Links in Flash Movies with Dreamweaver ................................................................814 Triggering Behaviors from Flash Movies ..................................................................................815 Editing Flash Movies from within Dreamweaver ......................................................................817 Summary ..................................................................................................................................818

xxiii

Contents

Chapter 26: Adding Video to Your Web Page . . . . . . . . . . . . . . . . . 821 Video on the Web ....................................................................................................................821 The Flash Video Revolution ......................................................................................................822 Encoding video ..............................................................................................................822 Progressive download versus streaming ..........................................................................824 Inserting Flash video ......................................................................................................824 Publishing Flash video files ............................................................................................827 Modifying Flash video parameters ..................................................................................828 Mainstream Streaming Media ..................................................................................................830 RealMedia ......................................................................................................................830 QuickTime ....................................................................................................................831 Windows Media ............................................................................................................832 Working with Video Clips ........................................................................................................833 Linking to video ............................................................................................................835 Embedding video ..........................................................................................................835 Playing Videos in Dreamweaver ................................................................................................836 Inserting QuickTime Movies ....................................................................................................836 QuickTime versions ......................................................................................................841 Playing QuickTime VR ..................................................................................................841 Streaming with RealMedia ........................................................................................................844 Creating RealMedia metafiles ........................................................................................844 Inserting RealMedia in your Web page ..........................................................................844 Summary ..................................................................................................................................846

Chapter 27: Using Audio on Your Web Page . . . . . . . . . . . . . . . . . 847 Digital Audio Fundamentals ....................................................................................................847 File formats ....................................................................................................................848 Making audio files lighter ..............................................................................................849 MIDI Files ................................................................................................................................850 MP3 Mini-Primer ....................................................................................................................851 Player support ................................................................................................................852 Encoding MP3 ..............................................................................................................853 Linking to Audio Files ..............................................................................................................853 Embedding Sounds and Music ................................................................................................854 Playing Background Music ......................................................................................................856 Targeting Specific Plugins ........................................................................................................857 Windows Media Player audio ........................................................................................857 Using embed with ActiveX ............................................................................................859 Installing Streaming Audio ......................................................................................................860 Working with floating or embedded RealAudio players ..................................................860 Accessing RealAudio parameters ....................................................................................863 Integrating Podcasts ................................................................................................................863 Podcast XML feeds ........................................................................................................864 Linking to podcasts and feeds ........................................................................................865 Summary ..................................................................................................................................866

xxiv

Contents

Part VI: Enhancing Productivity and Web Site Management

867

Chapter 28: Using Dreamweaver Templates . . . . . . . . . . . . . . . . . 869 Understanding Templates ........................................................................................................869 Creating Your Own Templates ..................................................................................................871 Using Editable Regions ............................................................................................................872 Marking existing content as editable ..............................................................................872 Inserting a new editable region ......................................................................................873 Creating links in templates ............................................................................................874 Locking an editable region ............................................................................................876 Adding Content to Template Documents ..................................................................................876 Making Attributes Editable ......................................................................................................879 Setting Editable Attributes ........................................................................................................881 Enabling Repeating Regions ....................................................................................................883 Modifying a repeating region ..........................................................................................884 Constructing a repeating table ........................................................................................885 Establishing Optional Regions ..................................................................................................888 Combining editable and optional regions ......................................................................891 Setting optional region properties ..................................................................................891 Evaluating template expressions ....................................................................................892 Template expression examples ......................................................................................896 Nesting Templates ....................................................................................................................901 Working with Templates in the Assets Panel ............................................................................903 Creating a blank template ..............................................................................................904 Opening and deleting templates ....................................................................................905 Applying templates ........................................................................................................905 Mapping inconsistent template regions ..........................................................................906 Updating Templates ................................................................................................................907 Removing Template Markup ....................................................................................................908 Deleting template markup individually ..........................................................................908 Removing template markup from an entire page ............................................................908 Exporting a site without template markup ....................................................................908 Changing the Default Document ..............................................................................................909 Summary ..................................................................................................................................910

Chapter 29: Using Repeating Elements . . . . . . . . . . . . . . . . . . . . 911 Dreamweaver Library Items ......................................................................................................911 Using the Library Assets Panel ..................................................................................................912 Adding a Library item ....................................................................................................913 Moving Library items to a new site ................................................................................914 Inserting a Library item in your Web page ....................................................................914 Deleting an item from the Library ..................................................................................916 Renaming a Library item ................................................................................................917 Editing a Library Item ..............................................................................................................918 Updating Your Web Sites with Libraries ..................................................................................920

xxv

Contents

Applying Server-Side Includes ..................................................................................................922 Adding server-side includes ..........................................................................................923 Editing server-side Includes ..........................................................................................924 Summary ..................................................................................................................................925

Chapter 30: Maximizing Browser Targeting . . . . . . . . . . . . . . . . . 927 Converting Pages in Dreamweaver ..........................................................................................928 Validating Your Code ................................................................................................................929 Setting Validator preferences ..........................................................................................930 Checking Your Page for Compatibility ......................................................................................933 Checking your pages ......................................................................................................937 Using the results of the Browser Compatibility Check ....................................................940 Summary ..................................................................................................................................942

Chapter 31: Building Web Sites with a Team . . . . . . . . . . . . . . . . . 943 Following Check In/Check Out Procedures ..............................................................................944 Check In/Check Out overview ......................................................................................944 Enabling Check In/Check Out ......................................................................................946 Checking files in and out ..............................................................................................947 Keeping Track with Design Notes ............................................................................................949 Setting Up for Design Notes ..........................................................................................950 Setting the status with Design Notes ..............................................................................951 Creating custom Design Notes ......................................................................................952 Viewing Design Notes ....................................................................................................953 Browsing File View Columns ....................................................................................................954 Generating Reports ..................................................................................................................956 Outputting HTML Reports ............................................................................................958 Using Workflow reports ................................................................................................959 Administering Adobe Contribute Sites ....................................................................................960 Setting Up Contribute Compatibility ..............................................................................962 Entering sitewide administrator settings ........................................................................963 Establishing Contribute roles ........................................................................................965 Connecting users ..........................................................................................................975 Rolling back a Contribute page in Dreamweaver ............................................................978 Integrating Dreamweaver with Visual SourceSafe ....................................................................980 Communicating with WebDAV ................................................................................................981 Summary ..................................................................................................................................983

Chapter 32: Integrating with XML and XSLT . . . . . . . . . . . . . . . . . 985 Understanding XML ................................................................................................................985 Exporting XML ........................................................................................................................987 Importing XML ........................................................................................................................990 Building Your Own XML Files ..................................................................................................990 Styling with XSL ......................................................................................................................991 Including XSLT fragments ..............................................................................................992 Building full XSLT pages ..............................................................................................1001 Summary ................................................................................................................................1007

xxvi

Contents

Part VII: Extending Dreamweaver

1009

Chapter 33: Customizing Dreamweaver . . . . . . . . . . . . . . . . . . 1011 Adding New Commands ........................................................................................................1012 Understanding Dreamweaver commands ....................................................................1012 Recording and replaying commands ............................................................................1015 Scripting commands ....................................................................................................1018 Useful command routines ............................................................................................1020 Managing Menus and Keyboard Shortcuts ..............................................................................1025 Handling History panel commands ..............................................................................1026 Using the Keyboard Shortcut editor ............................................................................1026 Adjusting the menus.xml file ......................................................................................1029 Building menu commands ..........................................................................................1032 Working with Custom Tags ....................................................................................................1033 Customizing Property Inspectors ............................................................................................1035 Coding a Property inspector ........................................................................................1036 Designing a Property inspector ....................................................................................1039 Making Custom Floating Panels ............................................................................................1040 Developing Translators ..........................................................................................................1042 Translator functions ....................................................................................................1043 Locking code ..............................................................................................................1045 Extending C-Level Libraries ..................................................................................................1046 Calling C-level extensions ............................................................................................1046 Building C-level extensions ..........................................................................................1048 Customizing Your Tag Libraries ..............................................................................................1049 Editing tag libraries, tags, and attributes ......................................................................1049 Creating and deleting tag libraries, tags, and attributes ................................................1050 Importing a DTD or schema to create a new tag library ................................................1051 Summary ................................................................................................................................1052

Chapter 34: Handling Server Behaviors . . . . . . . . . . . . . . . . . . . 1053 Understanding Server Behaviors ............................................................................................1053 Applying and Managing Server Behaviors ..............................................................................1054 Inserting and removing server behaviors ......................................................................1055 Editing the parameters ................................................................................................1055 Standard Server Behaviors ......................................................................................................1056 Recordset (Query) ........................................................................................................1056 Repeat Region ..............................................................................................................1057 Recordset Paging ..........................................................................................................1058 Move To Specific Record ..............................................................................................1059 Show Region ................................................................................................................1060 Go To Detail Page ........................................................................................................1061 Go To Related Page ......................................................................................................1062 Insert Record ..............................................................................................................1063 Update Record ............................................................................................................1064 Delete Record ..............................................................................................................1065

xxvii

Contents

User authentication ......................................................................................................1066 Dynamic elements ........................................................................................................1069 Stored procedure/command/callable ............................................................................1074 Special JSP server behaviors ........................................................................................1076 ASP.NET server behaviors ............................................................................................1078 Installing Additional Server Behaviors ..................................................................................1080 Creating Custom Server Behaviors ..........................................................................................1082 Summary ................................................................................................................................1085

Part VIII: Appendix

1087

Appendix A: What’s on the CD-ROM? . . . . . . . . . . . . . . . . . . . 1089

Bonus Chapters

On the CD-ROM

Bonus Chapter 1 Bonus Chapter 2 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1093 End-User License Agreement . . . . . . . . . . . . . . . . . . . . . . . . . 1113

xxviii

D

reamweaver continues to grow with each release, and only a team of Web-savvy personnel can describe its capabilities with grace and precision. I’m extremely happy and proud to have had just such a team involved in bringing Dreamweaver CS3 Bible to life.

Looking for a technical editor par excellence? Well, keep looking, ‘cause I’m hanging onto mine. Derren Whiteman has made sure the material is on the technical straight-and-narrow with his wide-ranging expertise and adept juggling of multiple operating systems and configurations. Thanks for all your work, Derren; you’ve really had a significant impact on the book. Adobe has been wonderfully supportive of my efforts to bring out the most detailed Bible possible. I can only imagine the collective groan that goes up when yet another e-mailed question from me—with a deadline, no less—arrives. Warm thanks and heartfelt appreciation to Jay London, Randy Edmunds, Alain Dumesney, Lori Hylan-Cho, and all the other Dreamweaver engineers and techs who allowed me to pick their brains. I’d also like to single out the Dreamweaver Technical Support staff, whose answers to users’ queries have been tremendous sources of information. Finally, I, and the rest of the Dreamweaver community, am beholden to Kevin Lynch and Paul Madar for their vision and hard work in bringing this dream home. To me, there’s no higher compliment than to be told that I know my business. Well, the folks I work with at Wiley sure know their business: Executive Editor Chris Webb and all the additional support staff. I’d like to call out all the hard work and wonderful patience of Maryann Steinhart. One last note of appreciation: To all the people who took a chance with some of their hard-earned money and bought the previous editions of this book. That small sound you hear in the background is me applauding you in thanks for your support. I hope my efforts continue to be worthy.

xxix

D

reamweaver CS3 stands at the center of a complex series of overlapping worlds. In one realm, designers of static Web pages are looking to expand their knowledge base into data-driven sites. Over there, you’ll find application developers—some savvy in Active Server Pages and ASP.NET, some in ColdFusion, and others in PHP—anxious to develop for the Internet. The spectrum of experience in both camps runs the gamut from eager novice to experienced professional, all of whom benefit from the advanced style capabilities of Cascading Style Sheets (CSS). There’s yet another group of prospective Web craftsmen and artists who want to do it all and are looking for a place to start. Dreamweaver CS3 is the one program robust enough for them all, and the Dreamweaver CS3 Bible is your guidebook to all its features and capabilities. What’s in a name? In the case of Adobe’s Dreamweaver, you find one of the most appropriate product names around. Web page design is a blend of art and craft; whether you’re a deadline-driven professional or a vision-filled amateur, Dreamweaver provides an intuitive way to make your Web visions a reality. Dreamweaver implies development, and it excels at producing multifaceted Web pages that bring content locked in a data store to the surface. To use this book, you need only two items: the Dreamweaver software and a desire to make cutting-edge Web pages. (If you don’t have Dreamweaver, you can download a trial copy from www.adobe.com.) From quick design prototyping to ongoing Web site management, Dreamweaver automates and simplifies much of a Webmaster’s workload. Dreamweaver is not only the first Web authoring tool to bring the ease of visual editing to an HTML-code–oriented world, it also brings a point-and-click interface to complex coding whether server-side or client-side. The Dreamweaver CS3 Bible is designed to help you master every nuance of the program. Are you styling your pages and creating your layouts with CSS? Are you building multipage Web applications? Are you creating a straightforward layout with the visual editor? Do you need to extend Dreamweaver’s capabilities by building your own custom objects? With Dreamweaver and this book, you can weave your dreams into reality for the entire world to experience.

Who Should Read This Book? Dreamweaver attracts a wide range of Web developers. Because it’s the first Web authoring tool that doesn’t rewrite original code, veteran designers are drawn to using Dreamweaver as their first visual editor. Because it also automates complicated effects, beginning Web designers are interested in Dreamweaver’s power and performance. Dreamweaver CS3 Bible addresses the full spectrum of Web professionals, providing basic information on HTML if you’re just starting, as well as advanced tips and tricks for seasoned pros. Moreover, this book is a complete reference for everyone working with Dreamweaver on a daily basis.

xxxi

Introduction

What Hardware and Software Do You Need? Dreamweaver CS3 Bible includes coverage of Dreamweaver CS3. Written to be platform-independent, this book covers both Macintosh and Windows versions of Dreamweaver CS3.

Macintosh Adobe recommends the following minimum requirements for running Dreamweaver on a Macintosh: n n n n n n

Power PC G4 or G5, Intel-based Macs Mac OS 10.4.8 512MB of available RAM 1.4GB of available disk space 16-bit video card capable of 1024 x 768 resolution DVD-ROM drive

Windows Adobe recommends the following minimum requirements for running Dreamweaver on a Windows system: n n n n n n

NOTE

Intel Pentium 4 or 5 processor, 2GHz Windows XP SP2 or Vista Home Premium, Business, Enterprise, Ultimate 512MB of available RAM 1GB of available disk space 16-bit video card capable of 1024 x 768 resolution DVD-ROM drive These are the minimum requirements. As with all graphics-based design tools, more capability is definitely better for using Dreamweaver, especially in terms of memory and processor speed.

How This Book Is Organized Dreamweaver CS3 Bible can take you from raw beginner to full-fledged professional if read cover to cover. However, you’re more likely to read each section as needed, taking the necessary information and coming back later. To facilitate this approach, Dreamweaver CS3 Bible is divided into seven major task-oriented parts. After you’re familiar with Dreamweaver, feel free to skip around the book, using it as a reference guide as you increase your own knowledge base. The early chapters present the basics, and all chapters contain clearly written steps for the tasks you need to perform. In most chapters, you encounter sections labeled Dreamweaver Techniques, completely rewritten for this version of the Dreamweaver Bible. Dreamweaver Techniques are step-by-step instructions for accomplishing specific Web designer tasks; taken together, the Dreamweaver Techniques constitute an entire howto course. These step-by-step instructions are self-contained in each chapter, so you’re free to explore them in any order you choose. You’ll find all the practice files for working on the Techniques on the CD-ROM, both as starting points and as completed files. Naturally, you can also use the Dreamweaver Techniques as stepping stones for your own explorations into Web page creation.

xxxii

Introduction

You’ll find yet another cool addition to the Dreamweaver Bible on the CD-ROM: interactive simulations for each Dreamweaver Technique. Created by master trainer Mark Fletcher with Adobe Captivate, these simulations give you the opportunity to practice all the steps in each Technique. As my dad used to say, “Get it in your hand and you’ll get it in your head.” The accompanying CD-ROM also offers a vast number of additional Dreamweaver server behaviors, objects, commands, and other extensions, in addition to relevant code from the book.

Part I—Laying the Groundwork in Dreamweaver CS3 Part I begins with a look at what’s new in Dreamweaver CS3—and there’s an awful lot to cover. Next up, you’ll find an overview of Dreamweaver’s philosophy and design. To get the most out of the program, you need to understand the key advantages it offers over other authoring programs and their deficiencies, which Dreamweaver addresses. Part I takes you all the way to setting up your first site.

Part II—Designing and Crafting Core Pages Although Dreamweaver is partly a visual design tool, its roots derive from the language of the Web: HTML. Part II gives you a solid foundation in the basics of HTML, even if you’ve never seen code. It also shows you how to get the most out of Dreamweaver’s code environment with any language. Chapter 6 describes what you need to know about the overall structure of a Web page, including the all-important tags. Reflecting the current emphasis in Web design on Cascading Style Sheets, Chapter 7 lays the foundation to CSS. In this chapter, you learn the basics of CSS, as well as how to define and apply styles in Dreamweaver. Following the introduction to CSS, you learn the three fundamentals of static Web pages: text, images, and links. In Chapters 8, 9, and 10, you explore how to completely incorporate these elements.

Part III—Adding Advanced Design Features After you master the basics, you’re ready to learn about some of Dreamweaver’s true power tools in Part III. First up is one of the most important constructs of HTML: tags, also known in Dreamweaver as AP elements. Chapter 11 examines this brave new world of pixel-perfect positioning, AP elements that fly in and then disappear as if by magic, and Web sites that can change their look and feel at the click of a mouse. Chapter 12 offers an in-depth look at the capabilities of Dreamweaver behaviors. These bring a great deal of interactivity to AP elements specifically and to your Web page in general. Each standard behavior is covered in detail with step-by-step instructions. Chapter 13 explores the various uses of tables—from a clear presentation of data to organizing entire Web pages. Here you learn how to use Dreamweaver’s visual table editing capabilities to resize and reshape your HTML tables quickly. Forms are an essential element in dynamic Web page design, and you learn all about them in Chapter 14. Chapter 15 presents another fundamental HTML option: lists. You study the list in all its forms: numbered lists, bulleted lists, definition lists, nested lists, and more. Chapter 16 investigates the somewhat complex world of frames. You see how Dreamweaver has greatly simplified the task of building and managing these multifile creations, particularly with the Frame objects. You also learn how to handle more advanced design tasks such as updating multiple frames with just one click. If you want to delve into the 4th dimension in Web design, you get an opportunity in Chapter 17 with the exploration of timelines. Chapter 18 takes the Web to a whole new level: Web 2.0 to be exact. With the introduction of the Spry framework, Adobe has made the sophisticated inner-workings of Ajax accessible to every Web developer.

xxxiii

Introduction

This chapter explains what Ajax is and how Spry fits into the picture before diving into the wide range of Spry tools available in Dreamweaver CS3, including Spry Data, Spry Widgets, and Spry Effects.

Part IV—Incorporating Dynamic Data Chapter 19 begins an in-depth investigation of Dreamweaver’s power to create dynamic Web pages by describing how to set up your basic connections and recordsets. Chapter 20 explains how to insert text from a data source onto your Web page and how to format it after it’s incorporated. You also see how to relate other Web page elements—such as images, Flash movies, and other media files—to a data source. Chapter 21 continues the exploration by delving into Dreamweaver’s powerful Repeat Region server behavior as well as discussing techniques for hiding and showing your data at will. One of Dreamweaver’s most useful features, the Live Data Preview, is examined extensively in Chapter 22. Chapter 23 enters the world of multipage applications and explains how variables and other data can be passed from one page to another.

Part V—Including Multimedia Elements In recent years, the Web has moved from a relatively static display of text and simple images to a full-blown multimedia circus with streaming video, background music, and interactive animations. Part V contains the power tools for incorporating various media files into your Web site. Graphics remain the key medium on the Web today, and Adobe’s graphics programs are the world leaders. Chapter 24 delves into methods for incorporating both Adobe Photoshop and Adobe Fireworks graphics as well as graphics management through Adobe Bridge. Special focus is given to the Dreamweaver-toPhotoshop and Dreamweaver-to-Fireworks communication links and how your Web production efforts can benefit from it. In addition to Dreamweaver, Adobe is perhaps best known for one other contribution to Web multimedia: Adobe Flash. Chapter 25 explores the possibilities offered by incorporating Flash and Shockwave movies into Dreamweaver-designed Web pages and includes everything you need to know about configuring MIME types. You also find step-by-step instructions for building Shockwave inline controls and playing Shockwave movies in frame-based Web pages, as well as how to add Flash Buttons, Flash Text, and the new Flash elements. Chapter 26 covers digital video in its many forms—downloadable AVI files, streaming RealVideo displays, panoramic QuickTime movies, and the newest, hottest media: Flash video. Chapter 27 focuses on digital audio, with coverage of standard WAV and MIDI sound files as well as the newer streaming audio formats like MP3.

Part VI—Enhancing Productivity and Web Site Management Although Web page design gets all the glory, Web site management pays the bills. In Part VI, you see how Dreamweaver makes this essential part of any Webmaster’s day easier to handle. Chapter 28 starts off with a look at the use of Dreamweaver Templates and how they can speed up production while ensuring a unified look and feel across your Web site. Chapter 29 covers the Library, which can significantly reduce any Webmaster’s workload by providing reusable—and updatable—page elements. Chapter 30 describes Dreamweaver’s built-in tools for maintaining cross- and backward-browser compatibility, including the essential Browser Compatibility Check, which reviews your page for rendering issues in a number of modern browsers. Until now, individual Web developers have been stymied when attempting to integrate Dreamweaver into a team development environment. File locking was all too easily subverted, allowing team members to

xxxiv

Introduction

inadvertently overwrite revisions. Site reports were limited in scope and output only to HTML, and, worst of all, version control was nonexistent. Dreamweaver CS3 tackles all these concerns while laying a foundation for future connectivity. In Chapter 31, you see how you can tie Dreamweaver into an existing Visual SourceSafe or WebDAV version control system. Other new features covered include custom file view columns and enhanced Design Notes accessibility. I can’t think of any new technology on the Web that has gained widespread acceptance as quickly as XML has. In a nutshell, XML (short for Extensible Markup Language) enables you to create your own custom tags that make the most sense for your business or profession. Although XML doesn’t enjoy full browser support as of this writing, it’s only a matter of time—and little time at that. Chapter 32 shows you how to apply this fast-approaching technology of tomorrow in Dreamweaver today, with a special section on Dreamweaver CS3’s new XML/XSLT technology.

Part VII—Extending Dreamweaver Dreamweaver is a program with immense capabilities for expanding its own power. Chapter 33 explores the brave new world of Dreamweaver extensibility, with complete coverage of using and building commands as well as custom tags, translators, floaters, and C-level extensions. With its own set of objects and behaviors, Dreamweaver complements HTML’s extensibility. Finally, Chapter 34 examines server behaviors, describing every standard one in detail and then exploring the use of the Server Behavior Builder, Dreamweaver’s tool for creating custom server behaviors.

Appendix The appendix describes the contents of the CD-ROM that accompanies this book. Throughout this book, whenever you encounter a reference to files or programs on the CD-ROM, please check this appendix for more information.

Conventions Used in This Book I use the following conventions throughout this book.

Windows and Macintosh Conventions Because Dreamweaver CS3 Bible is a cross-platform book, it gives instructions for both Windows and Macintosh users when keystrokes for a particular task differ. Throughout this book, the Windows keystrokes are given first; the Macintosh are given second in parentheses, as follows: To undo an action, press Ctrl+Z (Command+Z). The first action instructs Windows users to press the Ctrl and Z keys in combination, and the second action (in parentheses) instructs Macintosh users to press the Command and Z keys together.

Key Combinations When you are instructed to press two or more keys simultaneously, each key in the combination is separated by a plus sign. For example: Ctrl+Alt+T (Command+Option+T) The preceding tells you to press the three listed keys for your system at the same time. You can also hold down one or more keys and then press the final key. Release all the keys at the same time.

xxxv

Introduction

Mouse Instructions When instructed to click an item, move the mouse pointer to the specified item and click the mouse button once. Windows users use the left mouse button unless otherwise instructed. Double-click means clicking the mouse button twice in rapid succession. When instructed to select or choose an item, you can click it once as previously described. If you are selecting text or multiple objects, click the mouse button once, press Shift, and then move the mouse to a new location and click again. The color of the selected item or items inverts to indicate the selection. To clear the selection, click once anywhere on the Web page.

Menu Commands When instructed to select a command from a menu, you see the menu and the command separated by an arrow symbol. For example, when instructed to execute the Open command from the File menu, you see the notation File ➪ Open. Some menus use submenus, in which case you see an arrow for each submenu, as follows: Insert ➪ Form Object ➪ Text Field.

Typographical Conventions I use italic type for new terms and for emphasis and boldface type for text that you need to type directly from the computer keyboard.

Code A special typeface indicates HTML or other code, as demonstrated in the following example:

Untitled Document



This code font is also used within paragraphs to designate HTML tags, attributes, and values such as , bgcolor, and #FFFFFF. All HTML tags are presented in lowercase, as written by Dreamweaver, although browsers are not generally case-sensitive in terms of HTML. The code continuation character (;) at the end of a code line indicates that the line is too long to fit within the margins of the printed book. You should continue typing the next line of code before pressing the Enter (Return) key.

Navigating This Book Various signposts and icons are located throughout Dreamweaver CS3 Bible for your assistance. Each chapter begins with an overview of its information and ends with a quick summary. Icons appear in the text to indicate important or especially helpful items. Here’s a list of the icons and their functions:

xxxvi

Introduction

Tips provide you with extra knowledge that separates the novice from the pro.

TIP NOTE

Notes provide additional or critical information and technical data on the current topic.

NEW FEATURE

Sections marked with a New in Dreamweaver icon detail an innovation introduced in Dreamweaver CS3.

CROSS-REF

Cross-Reference icons indicate places where you can find more information on a particular topic.

CAUTION ON the CD-ROM

The Caution icon is your warning of a potential problem or pitfall. The On the CD-ROM icon indicates that the accompanying CD-ROM contains a related file in the given folder. See the appendix for more information about where to locate specific items.

Further Information You can find more help for specific problems and questions by investigating several Web sites. Adobe’s own Dreamweaver Web site is the best place to start: www.adobe.com/products/dreamweaver/

I heartily recommend that you visit and participate in the official Dreamweaver forums: www.adobe.com/cfusion/webforums/forum/index.cfm?forumid=12

You can also e-mail me at [email protected]

I can’t promise instantaneous turnaround, but I answer all my mail to the best of my abilities.

xxxvii

Laying the Groundwork in Dreamweaver CS3 IN THIS PART Chapter 1 What’s New in Dreamweaver CS3

Chapter 2 Introducing Dreamweaver CS3

Chapter 3 Touring Dreamweaver

Chapter 4 Setting Your Preferences

Chapter 5 Setting Up Sites and Servers

What’s New in Dreamweaver CS3

S

afe to say, Adobe Dreamweaver CS3 is the most highly anticipated release of the world’s most popular Web authoring tool in recent memory. Why? First, and most critically, this is the first version of Dreamweaver since Adobe acquired Macromedia. Designers for both the graphic and Web industries have been wondering anxiously what changes this combination of software powerhouses would bring. Would Photoshop and Dreamweaver finally begin to work together? Would Dreamweaver become an Adobe interface clone? Would Dreamweaver even make the cut and continue to be produced — or would more and more Web designers around the world need to learn how to “go live”? The answer to the last question should be self-evident by the very book you’re holding in your hands. Dreamweaver has been welcomed into the Adobe family with open arms and fully integrated into the Creative Suites. You’ll find the other answers later in this chapter. Another factor fueling the anticipation is the wave of new design possibilities and standards-based implementations — collectively known as Web 2.0 — that have significantly reshaped the Web designer’s world since the previous version of Dreamweaver was released. As you’ll see in this chapter and throughout the book, the Dreamweaver team has accepted the technological challenge and responded with an abundance of innovative tools, an updated design philosophy, and jaw-dropping results. Dreamweaver CS3 does more than push the envelope: the envelope has been obliterated. Outside of platform enhancements — Dreamweaver is now compatible with the new Intel-based Macintosh systems as well as Windows Vista — changes in Dreamweaver CS3 can be grouped into four major divisions: Web 2.0, Adobe connectivity, CSS enhancements, and program-wide clean-up. This chapter provides a quick tour through each of these areas just to give you an idea of the power — and the thrill — that awaits you in Dreamweaver CS3.

3

IN THIS CHAPTER Moving into Web 2.0 with Spry Connecting to Photoshop and Bridge Improving CSS designs and productivity Implementing improvements everywhere

Part I

Laying the Groundwork in Dreamweaver CS3

Web 2.0 Spoken Here When the phrase Web 2.0 is spoken, a more robust, interactive experience comes to mind. At the heart of that experience is a technology known as Ajax, which is short for Asynchronous JavaScript and XML. Ajaxpowered pages are known for their seamless data flow, where only a portion of the page updates as needed. Advanced, less-intrusive JavaScript coding also falls under the Ajax/Web 2.0 umbrella — all of which leads to better, more satisfying Web sites. Dreamweaver CS3 emerges fully capable of building such Web sites through the Adobe framework for Ajax, Spry. The Spry framework, released by Adobe Labs (labs.adobe.com) in early 2006, makes it possible for Web designers to easily build Web 2.0–compatible pages without excessive coding. Dreamweaver CS3 has made it even easier; now, Ajax implementation is just a point-and-click away. There are three major Spry components in Dreamweaver CS3: Spry Data, Spry Widgets, and Spry Effects. Spry Data brings XML data right into any Web page — plain HTML or dynamic — presented with an Ajax flair. Connect an XML file as easily as attaching an external style sheet, drop in your Spry table and, before you can say W3C, you’ve got a working Ajax page (Figure 1-1). Dive deeper into the Spry framework to add column sorting, data filtering, and conditional display. FIGURE 1-1 Ajax comes to Dreamweaver CS3 through Spry Data objects.

Spry Widgets impact two major facets of Web design: layouts and forms. The Spry layout widgets included in Dreamweaver CS3 offer designers a wealth of new possibilities: standards-based menu bars, tabbed panels, accordion panels, and collapsible panels. Each layout widget is drop-dead simple to implement — just drag it onto the page and you’re good to go — and just as easy to modify. Spry form widgets neatly solve a Web designer core issue: validation. Now designers no longer need to agonize over the painstaking chore of validating each and every form element. The Spry Validation Form widgets (for text, textarea, select list, and checkbox form fields) include both the form field and validation, all in one drag-and-drop object. Error messages can be quickly modified in Design or Code view. No muss and certainly no more fuss. The final leg of the Web 2.0 tripod is Spry Effects. Have you visited a site recently to see full-sized images growing from thumbnails and then shrinking again, all under user control? How about portions of the Web

4

What’s New in Dreamweaver CS3

page that highlight quickly when loaded to attract your attention and then just as quickly fade from view? With Spry Effects, you can add these functions — and much, much more — to your pages so other designers can visit your sites with envy.

Adobe Connectivity I’ve spoken at a great many conferences over the years, for both dedicated Dreamweaver and general Web designer audiences. In my opening remarks, I typically try to get a sense of the crowd’s expertise by asking who uses what tools. Time and time again, I would see a great many folks using Photoshop and Dreamweaver together, even though there was no clear path and many barriers. Now, with Dreamweaver CS3, the barriers have been dashed and the path paved — not just to Photoshop, but to other products in the Adobe family as well. Dreamweaver CS3 supports Photoshop in two major ways. First, you can now open a Photoshop CS3 native format file (PSD) and export it to a Web-ready format, all inside of Dreamweaver. Open any PSD file, scale it, crop it, optimize it, and save it as a GIF, JPG, or PNG file in one slick operation (Figure 1-2). You say you’d rather just work directly from Photoshop and bring in images when needed? No problem. Now you can copy an image or layer (or even merged layers) in Photoshop and paste it into Dreamweaver; you’ll have the same opportunity to store your new image in whatever Web format is best. Better still, both methods of working give you the option to return to Photoshop to make any needed adjustments before smoothly sliding back into Dreamweaver. FIGURE 1-2 Open a Photoshop PSD or paste in a Photoshop layer and then export directly into Dreamweaver.

Just because Dreamweaver is now hanging with Photoshop doesn’t mean that it’s forgotten its old pal, Fireworks. Fireworks support has been fully maintained — and just wait until you get a look at the new Fireworks CS3! For those folks looking for the ultimate in creative, sweet (ahem!) integration, you can even forge a Photoshop to Dreamweaver to Fireworks and back to Dreamweaver workflow with little effort.

5

1

Part I

Laying the Groundwork in Dreamweaver CS3

For all these high-end graphics you’ll be producing and incorporating into your sites, you’re going to need a rock-solid visual browser with meta-tagging, advanced filtering, and multi-media support, right? Well, have I got a bridge for you — Adobe Bridge, to be precise. Dreamweaver CS3 now lets you browse your images in Bridge and drag and drop them right on the page (Figure 1-3). You can even send images from Bridge directly into Dreamweaver. FIGURE 1-3 With Adobe Bridge in compact mode, you can easily find just the right image to drop into Dreamweaver.

Our integration story wouldn’t be complete without mentioning Adobe Flash. Not only can you roundtrip with your Flash SWF files, opening up the source files, if necessary, but Flash movies, video, and compiled files are fully supported. Even better, Adobe’s industry-accepted solution to the Internet Explorer Active Content issue — the one that forces folks to click on any Flash content to see it — is totally integrated in Dreamweaver, for both new and legacy pages.

CSS Enhancements Here’s a headline many have been hoping to see for years: Dreamweaver CS3 Officially Embraces CSS. In all previous versions, Dreamweaver rendering reflected what was considered the real-world faced by most designers by displaying an Internet Explorer browser representation. Though it was (and still is) true that Internet Explorer is the browser most often used, the desire by Web designers to support standards was paramount. Dreamweaver now renders according to CSS specifications, as approved by W3C, the standards body of the Web. Rendering is just the beginning of the CSS enhancements waiting for you in Dreamweaver CS3. Beginners and seasoned professionals will delight in the new set of starter pages, professionally crafted with a wide range of CSS-based layouts. Not only are these starter pages a quick and easy way to get a leg up on your designs, they also are jam-packed with helpful comments and CSS insights.

6

What’s New in Dreamweaver CS3

CSS management takes a major leap forward with Dreamweaver CS3. New commands to move your CSS from one location to another — whether from an embedded

Comparing the link and the import methods, the link method is better supported among browsers, including Netscape 4.x. Because of Netscape 4.x’s lack of standards support in CSS and other issues, however, the link method isn’t necessarily your best choice. You can take advantage of Netscape 4.x’s lack of support for the import method to offset its rather quirky support of CSS in general. Create two style sheets: one to handle Netscape 4.x issues and one for newer browsers, such as Internet Explorer 4.x and up and Netscape 6. Use the link technique to bring in the NS4.x-based style sheet and import for the second style sheet. By writing the code in the following sequence, the second style sheet overrides the same selector rules in the first style sheet and is ignored by Netscape 4.x:

TIP



Embedded styles Embedded styles are those typically written into the actual file at the top of a Web page within a tag pair. Placing style sheets within the header tags has become a convention that many designers use, although you can also apply a style sheet anywhere on a page. The

214

Building Style Sheet Web Pages

The HTML comment tags

You’re not restricted to any particular line length or number of lines for comments. The text included between the opening of the comment,

or this one for .NET:

These TemplateParam tags are used by Dreamweaver to identify the editable attributes and provide their types and default values.

CAUTION

The default values set in Editable attributes are not rendered when viewing the template in the Design view, only in the template-derived document. This is a known bug in Dreamweaver.

Setting Editable Attributes After you’ve inserted your editable attributes in the template, Dreamweaver provides a straightforward user interface for editing them in template-derived documents. Whether you choose File ➪ New or select the template in the Assets panel to create your new document, you find a new command available under the Modify menu: Template Properties.

881

28

Part VI

Enhancing Productivity and Web Site Management

The Template Properties dialog box, shown in Figure 28-7, lists all the editable attributes found on a single page. Selecting each property brings up the editing options for that particular attribute type (text, number, color, URL, and true/false) and the current associated value. After modifying any or all of the template properties, Dreamweaver refreshes the page and displays the attributes with their new values. FIGURE 28-7 How you specify the value for an editable attribute in the Template Properties dialog box depends on the type of attribute.

With each of the Template Properties types, you have the option to allow the nested template to control the attribute. Select this option if you intend to save the current document as a template — thus creating a nested template — and if you want documents based on that nested template to set the attribute value. You can also choose this option when editing a nested template. Nested templates are covered in depth later in this chapter. To set the editable attributes on a template-based document, follow these steps: 1. Choose Modify ➪ Template Properties. The Template Properties dialog box is displayed. 2. Select the attribute to specify its value. 3. If you want to allow the attribute to be modified in a document based on a nested template, choose the Allow Nested Templates To Control This option. If the option is selected, the phrase pass through in parentheses replaces the attribute value editing options. 4. Enter the new value for the attribute. Depending on the type of attribute you select, you enter the value differently:

n For Text, Number, and URL type attributes, enter the new value in the text field next to the editable attribute name. n For Color type attributes, select the color picker to sample the desired color from the color palette or any area on the screen. You can also enter the hexadecimal color value or color name directly in the associated text field. n For True/False type attributes, select the Show Attribute Name option to set the value to true and deselect it to set the value to false. 5. To set the value of any other editable attribute on the page, choose the attribute from the list and repeat steps 3 and 4. 6. Click OK when you’re finished.

882

Using Dreamweaver Templates

Enabling Repeating Regions Data-driven pages handle repeating regions elegantly. A single row of a table is bound to data, and the application server returns as many requested rows as are available. However, not all pages are data-driven — and not all areas of a page that repeat can be bound to a data source. Dreamweaver provides solutions for both the serverside — the Repeat Region server behavior — and the client-side — the template-based repeating region feature. A repeating region, like an editable region, is applied to a template and may surround any tag-complete area (an area containing both a beginning tag and an ending tag) on a page. Typically, repeating regions wrap around the same type of areas as their server behavior cousins, such as table rows. However, unlike the Repeat Region server behavior, template repeating regions are expanded and manipulated manually in a template-based document. Keep in mind one other important aspect of repeating regions: They aren’t automatically editable — you have to include an editable region within a repeating region to make it so. The capability to lock specific portions of repeating regions makes this an extremely powerful feature. To insert a repeating region, follow these steps: 1. Select the portion of the page that you want to repeat. As noted earlier, a repeating region cannot overlap a tag pair. If you attempt to do this, Dreamweaver automatically extends the selection so that the entire tag is included. 2. Choose Insert ➪ Template Objects ➪ Repeating Region or, from the Templates group of the Insert bar, click the Repeating Region icon as seen in Figure 28-8.

FIGURE 28-8 Repeating regions are marked in templates with an outline and named tab, just like editable and optional regions. Repeating region

Repeating region icon

883

28

Part VI

Enhancing Productivity and Web Site Management

3. Enter a unique name in the New Repeating Region dialog box and click OK. Dreamweaver automatically provides a name, but as always, it’s best if you supply a meaningful name.

As mentioned earlier, repeating regions are not, by default, editable. To make a repeating region editable, select the content within the repeating region — not the repeating region itself — and then create an editable region by either clicking the Editable Region icon in the Templates menu of the Insert bar or choosing Insert ➪ Template Objects ➪ Editable Region. You must give the editable region a unique name as usual. You may notice that the repeating and editable regions tabs overlap, making it difficult to see the repeating region name. I’ve found it handy to use fairly long names for the repeating region, such as dataRowRepeating, and relatively short names for the editable region, such as dataRow, to enable me to see portions of both tabs. Also, although all template regions use the same color established in Preferences, the highlight for a repeating region is significantly lighter than that for editable regions. This color variation makes it much easier to identify the different types of regions.

CAUTION

Modifying a repeating region The power of repeating regions isn’t apparent until you open a template-based document containing one. With Invisible Elements enabled, you notice a series of buttons above each repeating region, as shown in Figure 28-9. With these controls, new entries — identical to the content contained within the repeating region — are added, deleted, or moved from one position to another. You can even copy and paste content within a repeating region. FIGURE 28-9 Entries can not only be added and removed in a repeating region; they can also be re-ordered.

Move entry up Add entry

Move entry down Remove entry

884

Using Dreamweaver Templates

To modify a repeating region in a template-based document, follow these steps: 1. Make sure View ➪ Visual Aids ➪ Invisible Elements is enabled. 2. Locate the four buttons above the repeating region:

n To add a new entry, click the Add (+) button. New entries are inserted below the current cursor selection. New entries are selected after they are created. n To delete an existing entry, position your cursor in the entry and click the Remove (–) button. n To move an entry down, place your cursor in the entry and click the Down button. n To move an entry up, place your cursor in the entry and click the Up button. 3. To copy and paste an entry, follow these steps:

a. Position your cursor in the entry. b. Choose Edit ➪ Repeating Entries ➪ Copy Repeated Entry. c. Choose Edit ➪ Paste or Edit ➪ Repeating Entries ➪ Paste Repeated Entry. If you prefer to work with Invisible Elements off, Dreamweaver provides corresponding menu options under both the main and context menus. In fact, the menu options are, in some ways, more powerful and can be immediate timesavers. Look in the main menu under Modify ➪ Templates ➪ Repeating Entries or, in the context menu under Templates, for these commands: n n n n n n

New Entry Before Selection New Entry After Selection New Entry At End New Entry At Beginning Cut Repeating Entry Copy Repeating Entry

n n n n n

Delete Repeating Entry Move Entry Up Move Entry Down Move Entry To Beginning Move Entry To End

Constructing a repeating table Repeating regions are used so commonly in tables that Dreamweaver provides a tool to create both a table and a repeating region at the same time. The Repeating Table object opens the standard table dialog box with the added capability to define which rows are within a repeating region. When inserted, the repeating region is all set up — and even includes a separate editable region in each cell as shown in Figure 28-10.

885

28

Part VI

Enhancing Productivity and Web Site Management

FIGURE 28-10 The Repeating Table object also includes editable regions for every cell in the repeating region rows.

To insert a Repeating Table, follow these steps: 1. In your template open for editing, position your cursor where you’d like the table to appear and choose Insert ➪ Template Objects ➪ Repeating Table. Alternatively, you can drag the Repeating Table icon from the Templates menu of the Insert bar. The Insert Repeating Table dialog box, shown in Figure 28-11, is displayed.

FIGURE 28-11 With the Repeating Table feature, you can define multiple rows to repeat.

2. Enter the values desired for the table attributes: Rows, Columns, Cell Padding, Cell Spacing, Width, and Border.

886

Using Dreamweaver Templates

CROSS-REF

If you’re not familiar with setting up a table, see Chapter 13.

3. Determine which rows of the table are to be repeated by entering the number of the first row in the Starting Row field and the number of the last row in the Ending Row field. For example, if you want only the second row of the table to repeat, your values are Starting Row: 2 and Ending Row: 2. However, if you want three rows to repeat starting with row 2, the values are Starting Row: 2 and Ending Row: 5. 4. Enter a unique name for the repeating region in the Region Name field or leave the Dreamweaversupplied default name. 5. Click OK when you’re finished.

After the table is created, notice that every cell in the designated repeating region is editable. Dreamweaver automatically inserts separate editable regions and names them incrementally EditRegion1, EditRegion2, and so on. By defining each cell as editable, rather than the entire row, Dreamweaver gives you the option to retain the editability on a cell-by-cell basis. If the cell should not be editable, position your cursor anywhere in the cell and choose Modify ➪ Templates ➪ Remove Template Markup.

Applying Additional Editable Regions

I

n the previous Dreamweaver Technique, you began the process of converting an existing page into a template. This Technique takes the next step and includes editable regions within a table. 1. Open the file created in the previous Dreamweaver Technique from the Templates folder, template_start.dwt. 2. You can apply editable regions to more than just text. Images are also good candidates, but first, it’s a good idea to create a generic image placeholder. Select the image of the house in the page and delete it. 3. From the Insert bar’s Common category, choose Images: Image Placeholder. 4. When the Image Placeholder dialog box opens, enter House in the Name field, 325 in Width, and 180 in Height; click OK when you’re done. 5. Select the image placeholder and, from the Property inspector’s Class list, choose imageRight. 6. With the image selected, choose Template: Editable Region. 7. In the New Editable Region dialog box, enter House Image in the Name field. 8. Tables are another page element that are easily made template-friendly. Select the value in the table cell next to the Bedrooms label and choose Templates: Editable Region. 9. In the New Editable Region dialog box, enter Bedrooms in the Name field and click OK. continued

887

28

Part VI

Enhancing Productivity and Web Site Management

continued 10. Repeat steps 6 and 7 to create editable regions for each of the values in the second column of the table; make your selections and name your editable regions like this: Selection

Editable Region Name

2. 1/2.

Bathrooms

1.

Acres

2500.

Square Feet

350.,000

Price

11. Save your page; click OK to acknowledge that some block content is within an editable region — if desired, you can select the Don’t Show Me This Message Again option to avoid this alert in the future. Editable regions are a cornerstone of the template structure and, as you can see, have a great number of uses.

Establishing Optional Regions One of my clients quite regularly wanted to feature one of his products over the others, so we developed a special logo exactly for that purpose. Whenever a product was to be highlighted, I modified the page to include the special logo rather than the standard one. Typically, this took up to a half-hour every time the change was made. Not only did I have to find the catalog page with the to-be-featured item and replace the logo — something else I had to hunt for — I also had to find the previously featured item page and revert the special logo placed there to the standard one. Not difficult work, but certainly tedious. Dreamweaver’s Optional Region feature is intended to reduce, if not eliminate, such tiresome chores. Content placed on a template within an optional region is conditionally shown or not shown on the template-derived page. In the just-described situation, this feature enables me to put both logos in the same

888

Using Dreamweaver Templates

template, each in its own optional region. By default, the main logo is shown, but if I decide not to show it, the special logo is shown in its place. Optional regions are extremely powerful. Optional regions work somewhat like a cross between repeating region and editable attributes. Like repeating regions, optional regions can surround any portion of a page; also, they are not editable by default, although it’s possible to create an editable optional region. After an optional region has been placed on the template page — as with editable attributes — the Template Properties dialog box is used to set the condition that displays or hides the content on a template-derived page. The conditions that control an optional region range from a basic true-false or Boolean statement to more complex, evaluated expressions. Reflecting this, the New Optional Region dialog box contains two tabs, Basic and Advanced. Under the Basic tab, you simply enter the name for the optional region and indicate whether to display the region by default. The Advanced tab, shown in Figure 28-12, gives you the opportunity to set the condition dependent on another existing template parameter or enter a template expression. FIGURE 28-12 Optional regions can be controlled by the state of another parameter directly or by the evaluation of a template expression.

NOTE

The Basic and Advanced tabs are mutually exclusive. The tab showing when OK is selected determines which template parameter is used.

Now, look at an example to see how both the Basic and Advanced approaches work together. Take the situation, described at the beginning of this section, which requires the use of a special logo every so often. To accomplish this, I create one optional region using the Basic tab of the New Optional Region dialog box. In this region, I just enter a name, mainLogoRegion, and enable the Show By Default option. In this region, I place my standard logo. The Basic tab creates a template parameter with code like this in the :

To set the parameters of an optional region in a template-based document, follow these steps: 1. Choose Modify ➪ Template Properties. The Template Properties dialog box is displayed. 2. Select the optional region you want to affect. 3. If you want to allow the optional region to be modified in a document based on a nested template, choose the Allow Nested Templates To Control This option. If the option is selected, the phrase pass through in parentheses replaces the Show Attribute Name options and appears in the list. 4. Otherwise, select the Show Attribute Name option to set the value to true and deselect it to set the value to false. 5. To set the value of any other optional regions on the page, choose the entry from the list and repeat steps 2 through 4. 6. Click OK when you’re finished.

891

28

Part VI

Enhancing Productivity and Web Site Management

Evaluating template expressions So far in this chapter, you’ve seen a little of what template expressions can do. With optional regions, template expressions are either set explicitly or evaluated to true or false. Template expressions can also be used throughout the template to great effect. Here is a short list of what’s possible with template expressions: Alternate the background color of a row contained in a repeating region. Automatically number each row in a repeating region. List the total number of rows in a repeating region. Show an optional region if a certain number of rows are used, or another region if that number of rows is exceeded. n Create sequential navigation links, allowing users to page to the next — or previous — document in a series. n Compute values displayed in a table, displaying items such as basic cost, tax, shipping, and total. n Display particular content depending on the position of the row — first, second, second-to-last, or last, for example — in the repeating region. n n n n

Two types of template expressions exist: template expression statements and inline template expressions. Template expression statements take the form of a specialized HTML comment, like this:

However, the _document prefix is implicit, and the same statement can be written like this:



895

28

Part VI

Enhancing Productivity and Web Site Management

//default display if none of the other conditions are met

In this code, if none of the conditions are met, a blank spacer image is displayed. As with other template expressions, multiple-if expressions must be coded by hand.

Template expression examples Template expressions obviously have a great deal of power built in, but how do you put it to use? Let’s look at some specific examples to help you get a better understanding of template expressions in general, as well as to give you some useful tools.

Alternating row background colors If you have a data-filled table of any significant size, alternating background colors for each row greatly increases the readability of the data. Template expressions provide a technique for specifying the two background colors — and automatically applying the right color whenever a new row is added in a repeating region. The key to this technique is the conditional operator. The conditional operator has three parts: the condition and the two results. If the condition is evaluated as true, the first result is applied; if it is not, the second is applied. In this case, the condition that is examined involves the _index property, which returns the position of the current row. By combining the _index property with the bitwise AND operator, &, like this: _index & 1 True is returned every other row, starting with the second row. The full template expression specifies the two colors as hexadecimal values; the second value specified (here, a light yellow) is returned in the first row, the first value (white) in the following row, and so on: @@((_index & 1) ? ‘#FFFFFF’ : ‘#FFFF99’)@@

This template expression is entered as the bgcolor attribute for the table row containing the data in a template’s repeating region. Note the use of the single quotes around the color values; quotes are needed in the conditional operator syntax, and single quotes are used here because Dreamweaver encloses the entire attribute value with double quotes. Here’s the code for the entire table in the template document. The tag containing the alternating row background color is shown in bold:

itemEdit

This code goes in the non-editable portion of the template’s . The example application, shown in Figure 28-17, uses three different template expressions. The first, @@priceVar@@, displays the parameter set with the Template Properties dialog box. The second shows the quantity price — which, here, is the base price times 3: @@(priceVar * 3)@@

898

Using Dreamweaver Templates

FIGURE 28-17 Template expressions, set in Template Properties, can be used to calculate other values in a template-based document.

The third expression displays the savings a buyer could receive by buying in quantity. In this example formula, the price times 3 is subtracted from the price times 5: @@((priceVar * 5) - (priceVar * 3))@@

Again, you can add whatever text or styles are necessary. Here, a dollar sign is placed in front of every expression that is followed by a decimal point and two zeros, as you can see in Listing 28-1. LISTING 28-1

Template Expressions Computing Example
Item SKU Price
priceEdit


The select attribute in the tag refers to the repeating element in the XML data. Dreamweaver inserts this code after you’ve identified the repeating item in the XPath Expression Builder (Repeat Region) dialog box. To set an XSLT fragment area to repeat in Dreamweaver, follow these steps: 1. Select the HTML and XSL data you want to repeat. It’s best to select the containing tag pair around the XSL data, like the or

. 2. From the Insert bar’s XSLT category, choose Repeat Region.

Alternatively, you can select Insert ➪ XSLT Objects ➪ Repeat Region; either approach opens the XPath Expression Builder (Repeat Region) dialog box. 3. In the XPath Expression Builder (Repeat Region) dialog box, select the element you want to repeat (see Figure 32-7). FIGURE 32-7 Choose the parent repeating element with the plus sign (disclosure triangle on the Macintosh).

Repeatable elements are identified with the double-angle brackets and plus sign, +. Be sure to choose the parent repeating element of any item you want to display. 4. Click OK when you’re done.

995

32

Part VI

Enhancing Productivity and Web Site Management

In Design view with Invisible Elements enabled, Dreamweaver displays a border around the repeated area with the label xsl:for-each.

Filtering XSL data While XPath Expression Builder (Repeat Region) dialog box makes setting up a repeat region a simple point-and-click operation, it also permits you to establish filters for the data. You could, for example, use this feature to limit the items from the Adobe XML News Aggregator (http://weblogs.macromedia .com/mxna/) to those concerned with Dreamweaver. Filters can be applied at the same as the XSLT Repeat Region or afterward. To apply a filter to an existing XSLT Repeat Region, follow these steps: 1. Select any of the XML data within the repeat region. 2. From the Tag Selector, choose . 3. In the Property inspector, click the lightning bolt next to the Select field. 4. When the XPath Expression Builder (Repeat Region) dialog box reopens, select Build Filter. The dialog box expands to display the filter controls. 5. Click Add (+) to start a new filter criteria. The initial filter criteria is set up to use the previously selected repeating data element in the Filter By column; your focus will be on choosing values for the Where, Operator, and Value columns. 6. Select the data element you want to filter by from the Where list. For example, if you wanted to filter by the subject field of the Adobe XML News Aggregator feed, you’d choose dc:subject. 7. Choose the operation you want to use in your filter from the Operator list. For string comparisons, you would select the equals sign, = or !=. Other operators include =, and . 8. Enter the desired filter keyword or other value in the Value column (see Figure 32-8).

If you’re using a text value in your filter criteria, surround the word or phrase with single quotation marks. Dreamweaver automatically converts these to their character entity equivalents — ' — so that the code will validate properly. 9. To add additional conditions, select either and or or from the And/Or column and repeat steps 5–8. 10. Click OK when you’re done.

996

Integrating with XML and XSLT

FIGURE 32-8 Choose the parent repeating element with the plus sign.

Test your XSLT fragment by previewing it in the browser, and Dreamweaver will create the necessary code to display the page.

Showing XSL data conditionally Another tool for shaping your XML data through XSL are the conditional XSLT objects in Dreamweaver. Both the XSLT Conditional Region and Multiple Conditional Region objects are used to display XML data or even standard HTML if your custom conditions are met. Unlike the filtering mechanism of the XSLT Repeat Region object, the conditional objects work with data that has already been made available to the page. You could, for example, display the optional description element from an RSS feed along with the Description label, but only if the description value exists. The XSLT Conditional Region, when applied by itself, tests for a single condition and renders the enclosed content if the condition is met, very much like an If-Then clause in programming. In fact, the code uses a the tag. For example, if you wanted to display text indicating the final item from an RSS feed, you’d use code like this:

Last item:



The test attribute checks to see if the position() function — which refers to the current item — is the same as the one the last() function returns and, if so, displays the text. To apply the XSLT Conditional Region object, follow these steps:

997

32

Part VI

Enhancing Productivity and Web Site Management

1. Select the text, image, page object, or code you want to make conditional in either Design or Code view. 2. From the Insert bar’s XSLT category, choose Conditional Region. 3. When the Conditional Region dialog box opens, enter the condition to evaluate in the Test field (see Figure 32-9).

FIGURE 32-9 Display or hide anything in an XSL fragment through the XSLT Conditional Region object.

4. Click OK.

While the XSLT Conditional Region object displays or doesn’t display some code based on a single condition, the Multiple Conditional Region is much more flexible. Although the Multiple Conditional Region object initially tests a single condition, it provides alternative output leading to an either/or code output. For example, say again you wanted to test for the final item and note it as such when it appears, but you also wanted to display other text, that is, Next item:, until it appears. In this situation, your XSL code would look like this:

Last item:



Next item:



You can add additional condition testing by including more tags prior to the tag. In Dreamweaver, this is accomplished by applying the XSLT Conditional Region object prior to the tag. By using the two conditional objects in conjunction with one another, you can test for as many conditions as you’d like and retain a default result. To create multiple XSLT conditional regions, follow these steps: 1. Select the text, image, page object, or code you want to render if the first condition is true. 2. From the Insert bar’s XSLT category, choose Multiple Conditional Region. 3. When the Multiple Conditional Region dialog box opens, enter the condition to evaluate in the Test field; click OK when you’re done.

998

Integrating with XML and XSLT

Dreamweaver displays three different tabs: the area surrounds the — which holds your previously selected content — and the area, which displays the placeholder text Content goes here, as shown in Figure 32-10. FIGURE 32-10 Dreamweaver displays the content for both outcomes in a Multiple Conditional Region.

If you just want to insert a single condition with a default result, you can stop here. 4. To add additional conditions and results, place your cursor in the placeholder content in the area and choose the tag in the Tag Selector. 5. Press the left-arrow key to move the cursor in front of the tag. 6. From the Insert bar’s XSLT category, choose Conditional Region. 7. When the Conditional Region dialog box opens, enter the next condition you want to evaluate in the Test field; click OK when you’re ready. Dreamweaver adds an tag with placeholder content. 8. Repeat steps 4–7 to add more conditional regions.

After you’ve created all the conditions desired, replace the placeholder text with the actual page elements or code you want rendered if the condition is true.

Styling XSLT fragments Although you can use CSS to style your XSLT fragments, you shouldn’t link to an external style sheet or embed styles within the fragment page. If you do, the CSS links and embedded styles will appear in the body of your document, along with the XSLT fragment. What’s the solution? Design-time style sheets.

CROSS-REF

To refresh your memory on how to implement a design-time style sheet, visit Chapter 7.

Typically, the page intended as the receptacle for the XSLT fragment is built prior to the fragment itself, along with the CSS style sheet. To view your XSLT fragment with the desired styles, attach the same style used by the host page as a design time style sheet. Once the design-time style sheet is in place, you can assign CSS styles to the XML data and surrounding structures, as shown in Figure 32-11.

999

32

Part VI

Enhancing Productivity and Web Site Management

FIGURE 32-11 Style XSLT fragments through Dreamweaver’s design-time style sheet feature.

Adding XSLT fragments to Web pages Once your XSLT fragment has been completed, it’s very straightforward to include it in your server model page. The actual code insertion is handled by a server behavior, XSL Transformation. To include an XSLT fragment, follow these steps: 1. Place your cursor where you’d like the XSLT fragment to appear. 2. From the Server Behaviors panel, click Add (+) and select XSL Transformation from the list. 3. In the XSL Transformation dialog box, click Browse next the XSLT File field. 4. When the Select File dialog box appears, locate the .xsl file that contains your fragment and click OK. Dreamweaver automatically populates the XML URI field with the address of the XML data, as shown in Figure 32-12.

FIGURE 32-12 The XSLT Transformation server behavior is used to select the XSLT fragment for inserting.

5. If you need to add any parameters to affect the XSLT fragment, click Add (+) in the XSLT Parameters area and enter the name and value of the parameter. 6. Click OK when you’re done.

Dreamweaver displays the XSLT fragment in the page; when selected, it appears as a solid, uneditable block. Unlike with server-side includes, a custom Property inspector is not available for inserted XSLT fragments. You can preview the page in the browser to see the data within the document.

1000

Integrating with XML and XSLT

The XSLT Parameters option found in the XSL Transformation dialog boxes allows you to set up parameters to pass to the XSLT fragment. You could, for example, create an XSLT parameter named ItemLimit with a value of 5 if you wanted to restrict the number of XML items shown to five or fewer. To ensure that the XSLT fragment works properly with this parameter, you’d need to set a filter criteria, as described in the “Filtering XSL Data” section, where the position() function is less than or equal to the variable $ItemLimit.

Building full XSLT pages As noted earlier, Dreamweaver gives you the option to create either an XSLT fragment or XSLT page. Although XSLT fragments are more typically used, the full XSLT page has advantages, including the capability to transform XML data on the client side without an application server such as ASP, ColdFusion, or PHP. Much of the information covered in the previous XSL fragment discussion applies to full XSLT pages. XML data appears in the Bindings panel and is bound to the page in the same manner. All the objects in the Insert bar’s XSLT category — including the Repeat Region and Conditional Region objects — can and should be used when crafting the XML data in an XSLT page.

Client-side pages Dreamweaver’s client-side XSL feature set is quite remarkable. With it, you can post XML data to be transformed by an XSLT page and viewed in a modern browser, without the use of server-side code. There are, however, a number of limitations: n n n n

Only full XSLT pages, and not XSLT fragments, can be used. The XML file must be stored locally; you can’t link to a remote XML feed. Both the XML and the XSLT page must be published to the same folder on the Web server. Only a limited number of browsers can be used to view the completed page.

It’s important to understand how XSLT pages interact with XML files to present the completed HTML page for the browser. Although XSL stands for Extensible Stylesheet Language, it’s not an exact parallel to Cascading Style Sheets. The primary difference is that an XSLT page contains HTML as well as XSLT code, unlike an external CSS file, which does not incorporate any HTML. Another key point is that both the XML and XSL files refer to one another, whereas with HTML and CSS, the only connection is the link or import code in the HTML page. The final concept to grasp is that you’re actually displaying the XML file, although it is transformed by the XSLT page. All links from other pages to show the data must be to the XML file. Here’s a general overview of the workflow for applying an XSLT page to an XML file: 1. Create an XSLT page. 2. Attach the XML data to the XSLT page. 3. Bind the XML data to the XSLT page. 4. From the XML page, link to the XSLT page. 5. Publish both files to the Web. 6. View the XML page.

Creating XSLT pages Dreamweaver provides two paths to approach the initial step, creating an XSLT page. You can build a page from scratch by choosing File ➪ New Document and then selecting the Basic page category and choosing XSLT (Full page). Or, if you have an existing HTML page you want to use to incorporate XML data, you can convert your HTML page into XSLT format.

1001

32

Part VI

Enhancing Productivity and Web Site Management

To convert an HTML page to an XSLT page, follow these steps: 1. Open the page you want to convert in Dreamweaver. 2. Choose File ➪ Convert ➪ XSLT 1.0.

Dreamweaver automatically saves the converted file under its original name with a new .xsl extension. For example, rss_feed.html becomes rss_feed.xsl.

CAUTION

Neither templates nor template-derived pages can be converted to an XSLT document. You’ll need to detach the template-derived page from the template before converting.

Attaching XML data to an XSLT page Attaching XML data to an XSLT page is just as straightforward as converting the page: 1. From the Bindings panel, click the XML link in the displayed step: Please Attach XML Source Document (see Figure 32-13).

FIGURE 32-13 Attach an XML file to an XSLT page through the Bindings panel.

2. When the Locate XML Source dialog box opens, make sure that the Attach A Local File On My Computer Or Local Area Network option is selected. 3. Click Browse to open the Select File dialog box and locate the XML file; click OK when you’ve found it. 4. Click OK in the Locate XML Source dialog box to confirm your choice.

Dreamweaver parses the XML file and displays the structure in the Bindings panel.

Binding the XML data Binding the data in an XSLT page is handled in exactly the same way as with an XSLT fragment. Data is dragged from the Bindings panel onto the page or double-clicked to be inserted at the cursor position. Likewise, repeat and conditional regions are applied in the same manner as described in the previous sections, “Repeating XSL Data,” “Filtering XSL Data,” and “Showing XSL Data Conditionally.” Unlike with XSLT fragments, it’s not necessary to use design time style sheets because the XSL page contains the HTML — as well as the link to the CSS external style sheets. Style can be applied to XML data just like any other page element.

1002

Integrating with XML and XSLT

Linking from an XML file All of the work so far has been centered on the XSLT page. Now it’s time to shift focus to the XML document. The first action is to link the XSLT page from the XML file. Recall that the browser actually loads the XML file, which in turn calls the XSLT page to transform the data into HTML. Client-side XSL transformations only work with local XML files. To use the data from an RSS feed, you’ll need to save the data page from your browser and publish it to your own Web

TIP server.

To link an XML to an XSLT page, follow these steps: 1. Open the XML file attached in the XSLT document. 2. Choose Commands ➪ Attach an XSLT Stylesheet. 3. When the Attach an XSLT Stylesheet dialog box opens (see Figure 32-14), click Browse to locate the XSLT file you’ve been working with.

FIGURE 32-14 Link your XML file to the appropriate XSLT Stylesheet.

CAUTION

Remember that both the XML and XSLT files must be in the same folder. If the XSLT file is in a separate folder, all the dependent files (including images, CSS, and includes) will not be found.

Publishing and viewing XML and XSLT files XML files can be published to the server like any other document in Dreamweaver. Best of all, Dreamweaver is smart enough to automatically publish your XSLT files — and any files referenced in that document — if you opt to put dependent files. It’s vital to remember that you must view the XML file in your browser and not the XSLT document. Given that the XSLT page has all the visual elements, this approach might feel a bit unnatural, but it’s the way it works. Only modern browsers are capable of viewing an XML file and processing the XSLT correctly on the clientside. Among capable browsers are: n n n n n n

Internet Explorer 6 and higher Netscape 8 and higher Mozilla 1.8 and higher Firefox 1.0.2 and higher Opera 8 and higher Safari 1.3 and higher

1003

32

Part VI

Enhancing Productivity and Web Site Management

Adding Data to an XSL Page

I

n this Technique, you convert an existing HTML page to XSLT format and then integrate data from an XML file into it. 1. From the Techniques site, expand the 31_XML folder and open the xml_start.htm file. 2. Choose File ➪ Convert ➪ XSLT 1.0. Dreamweaver converts the file and saves it as xml_start.xsl. 3. From the Bindings panel, select the XML link in step 1. 4. When the Locate XML Source dialog box appears, click Browse. 5. In the Locate Source XML for XSL Template dialog box, locate the properties.xml file in the 31_XML folder and click OK; click OK again to confirm your choice in the Locate Source XML dialog box. The Bindings panel is populated with the XML data schema.

6. From the Bindings panel, drag proptype to the cell under the Type label, desc under Description, bed under Bedrooms, and bath under Bathrooms. The next step is to apply a repeat region so that all the XML data will be displayed. 7. Select the proptype XML data placed on the page. 8. From the Tag Selector, choose the tag. 9. Choose Insert ➪ XSLT Objects ➪ Repeat Region.

1004

Integrating with XML and XSLT

10. When the XPath Expression Builder (Repeat Region) dialog box opens, choose property and click OK. 11. Save your page. The final step is to make the connection from the XML file to the XSLT page. 12. From the Files panel, open the properties.xml file in the 31_XML folder. 13. Choose Commands ➪ Attach an XSLT Stylesheet. 14. When the dialog box opens, click Browse and locate xml_start.xsl; click OK when you’re ready. 15. Save your XML page.

Preview the page by pressing F12 (Option+F12). If you’re using a recent browser version, you’ll see the XML data embedded in the page.

Server-side pages Though most designers and developers working with application servers will prefer to work with XSLT fragments, they do have the option of working with full XSLT pages. One advantage to taking the full page approach is that it allows for complete separation between the server-side code and the presentation code; organizations that deploy strictly divided Web teams may find this useful. Server-side XSL transformations suffer almost none of the drawbacks seen with client-side transformation: n Both full XSLT pages and XSLT fragments can be used. n The XML file can be stored locally or remotely. n Because the transformation occurs on the server-side, any browser can be used to view the transformed page.

1005

32

Part VI

Enhancing Productivity and Web Site Management

The only similar restriction for both client-side and server-side transformations is that if a local XML file is used for the data, both must be contained in the same folder. In Dreamweaver, server-side XSL transformations have been developed for most of the supported server models: ASP, ASP.NET, ColdFusion, and PHP. Only JSP is not supported. The workflow for creating a server-side XSLT transformation is similar to that of a client-side transformation, with a number of key differences: 1. Create an XSLT page. 2. Attach the XML data to the XSLT page. 3. Bind the XML data to the XSLT page. 4. Remove all HTML from your application page. 5. From the dynamic page, link to the XSLT page. 6. Publish both files to the Web. 7. View the dynamic page.

The primary differences pertain, as you might expect, to the server-oriented nature of the page. As noted in the fourth step, you’ll need to remove all HTML from your application page. This is a necessary action because the full XSLT page already contains the HTML framework — , , and tags — and to leave it in the application page would cause errors. Another difference is the manner in which the XSLT page is connected to the data. Rather than link to the XSLT page from the XML file, you apply a Dreamweaver server behavior in the dynamic page to create a connection to the XSLT file and its related XML data. To link to the full XSLT page from the dynamic page, follow these steps: 1. With the dynamic page open, choose Window ➪ Server Behaviors. 2. In the Server Behaviors panel, click Add (+) and select XSL Transformation from the list.

You may find the XSL Transformation box familiar; the same functionality is used when you create an XSLT fragment. 3. In the XSL Transformation dialog box, select the Attach A Local File On My Computer Or Local Area Network option if you want to incorporate data from a static XML file available on your system; use the Browse button to open the Select File dialog box or enter the path to the file by hand in the provided field. 4. If you’re displaying XML data from a file on the Web, click the Attach A Remote File On The Internet option and enter the full Internet address in the available field. 5. Click OK when you’re done. Before viewing on your Web server, you’ll need to publish your dynamic and XSLT page to your Web server. Unlike with the client-side transformation, Dreamweaver will not automatically include the XSLT file as a dependent file. When the files have been posted, view the dynamic page to see the page with the XML data and XSLT transformations.

1006

Integrating with XML and XSLT

Summary XML is a vital future technology that is knocking on the door of virtually every Web designer. As the development tools become more common, the Roundtrip XML capability within Dreamweaver makes interfacing with this new method of communication straightforward and effortless. When you work with XML, keep the following points in mind: n XML (Extensible Markup Language) enables content to be separated from the style of a Web page, creating information that can be more easily used in various situations with different kinds of media. n Tags in XML reflect the nature of the content, rather than its appearance. n Dreamweaver includes a Roundtrip XML facility that makes it possible to export and import XML files through Dreamweaver templates. n Use tag libraries to create custom XML tags and take advantage of Dreamweaver’s Code Hints and Code Completion. n XML data can be presented on the Internet with all the style of a standard Web page through the use of Extensible Style Sheet Transformation (XSLT). Dreamweaver includes functionality for creating either client-side or server-side XSLT pages. In the next chapter, you learn about customizing Dreamweaver, including how to use tag libraries.

1007

32

Extending Dreamweaver IN THIS PART Chapter 33 Customizing Dreamweaver

Chapter 34 Handling Server Behaviors

Customizing Dreamweaver

T

he Web is a dynamic environment, with new technologies continually emerging. Until recently, HTML standards were changing every year or so; even now, products are routinely introduced that use the Web as a jumping-off place for new methods and tools. Keeping pace with the constantly shifting work environment of the Web has been beyond the capabilities of any suite of Web authoring tools, much less a single one — until Dreamweaver debuted, of course. The initial version of Dreamweaver had a high degree of extensibility built right in, with its customizable HTML objects and JavaScript behaviors. Adobe continues to enhance this flexibility with each release. With the implementation of the W3C Document Object Model and a tremendous number of new API functions, objects, and behaviors, Dreamweaver features have been beefed up so that they are much more powerful than ever. In addition, Dreamweaver presents a host of ways to extend its power. Here are just some of the options: n Menus: The entire Dreamweaver menu system is completely customizable. You can add context menu items, rearrange the main menu, and even add completely new menus, all by modifying a single XML file. n Keyboard shortcuts: Adobe makes it easy to use the same keyboard shortcuts across its product line — even extending such ease to other products — with the Keyboard Shortcut editor. In addition to adopting the most comfortable set of key combinations, shortcuts for individual commands can be personalized. n Commands: Commands are JavaScript and HTML code that manipulate the Web page during the design phase, much as behaviors are triggered at runtime. n Custom tags: The rapid rise of XML makes custom-tag support essential in a professional Web authoring tool. Dreamweaver gives you the power to create any custom tag and control how it displays in the Document window.

1011

IN THIS CHAPTER Automating Web development with commands Including custom XML tags Examining new Property inspectors Modifying keyboard shortcuts Expanding Dreamweaver’s core functionality Translating server-side content

Part VII

Extending Dreamweaver

n Property inspectors: Custom Property inspectors go hand in hand with custom tags, enabling the straightforward entry of attributes and values in a manner consistent with the Dreamweaver user interface. n Custom panels: Dreamweaver enables you to create custom panels that supplement its variety of built-in panels. n Translators: Translators enable server-side and other content to be viewed in the Document window at design time, as well as in the browser at runtime. n C-level extensions: Some special uses require a root-level addition to Dreamweaver’s capabilities. Adobe’s engineers have “popped the hood” on Dreamweaver and made it possible for a C or C++ language library to interface with it through C-level extensions. n Custom toolbars and objects: The Insert bar and all other toolbars are now fully extensible, enabling quick and easy access to your most frequently used Dreamweaver objects and commands. n Tag libraries: Dreamweaver enables you to create, edit, and delete tag libraries. Although a few of these extension features require programming skills beyond those of the typical Web designer, most are well within the reach of an HTML- and JavaScript-savvy coder. Moreover, the Keyboard Shortcut editor employs a graphical user interface, making it accessible to all. As with behaviors and objects, the source code for all but the C-level extensions is readily available and serves as an excellent training ground. This chapter, combined with these standard scripts, provides all the tools you need to begin carving out your own personalized version of Dreamweaver.

Adding New Commands By their very nature, objects and behaviors are single-purpose engines. A custom object inserts a single block of HTML into the of a Web page, whereas custom behaviors add JavaScript functions to the and attributes of one tag. Commands, on the other hand, are multifaceted, multipurpose, goanywhere, and do-anything mechanisms. Commands can do everything objects and behaviors can do — and more. In fact, commands can even masquerade as objects. For all their power, commands are one of the most accessible of the Dreamweaver extensions. This section describes the basic structure of commands, as well as how to use the standard commands that ship with Dreamweaver. You can also find information about how to create your own commands and control their integration into Dreamweaver.

Understanding Dreamweaver commands When I first encountered commands, I thought, “Great! Dreamweaver now has a macro language.” I envisioned instantly automating simple Web design tasks. Before long, I realized that commands are even more powerful — and a bit trickier — than a macro recorder. Dreamweaver’s adoption of the W3C Document Object Model (DOM) is one of the factors that make commands feasible. The DOM in Dreamweaver exposes, or makes available, every part of the HTML page — every tag, every attribute, every bit of content — which can then be read, modified, deleted, or added to. Moreover, Dreamweaver commands can open, read, and modify other files on local systems.

1012

Customizing Dreamweaver

A command can have a parameter form or not, depending on how the command is written. Generally, commands are listed in the Commands menu, but by altering the menus.xml file (as discussed in the “Adjusting the menus.xml file” section later in this chapter), you can cause any command to appear as part of any other menu — or to not appear at all. Because one command can call another, such hidden commands are more easily modified. My original vision of a macro recorder came true with the commands Start Recording and Play Recorded Command. Now, any onscreen action can be instantly logged and replayed — and through the History panel, even converted into a permanent, repeatable command. So how, specifically, are commands being used? The following list describes some of the commands that have been built by Web designers outside Adobe: Tag Stripper: Removes all instances of any tag from a Web page. By Massimo Foti. Breadcrumbs: Automatically adds navigation elements on a page. By Paul Davis. Borderless Frames: Sets all frames in a frameset to no borders. By Massimo Foti. Add Old Browser Message: Inserts a message that can be seen only by browsers that do not support the W3C DOM. By Rachel Andrews. n Replicator: Duplicates any selected element any number of times. By this book’s author, Joseph Lowery.

n n n n

As is obvious from this list, commands come close to being limited only by the author’s imagination. For further evidence of just how useful commands can be, the following sections look at a few of Dreamweaver’s standard commands. Dreamweaver comes with a number of standard commands that, in addition to adding some extra functionality, give you a taste of just how powerful commands can be. You can find a full description of them in Chapter 3.

CROSS-REF

The Apply Source Formatting and Apply Source Formatting to Selection commands All the code created by Dreamweaver is structured according to the current Tag Library settings. The Tag Library identifies which codes are indented and which are on their own lines, as well as numerous other specifications regarding HTML writing. Occasionally, a Web designer must work with Web pages created earlier, by other designers using other programs, or even by hand. The Apply Source Formatting and Apply Source Formatting to Selection commands can rewrite the original code — of an entire Web page or a selected part of the page, respectively — so that it is structured according to the current Tag Library settings. The more accustomed your eye is to following Dreamweaver-style HTML, the more you value this command.

NOTE

You learn more about the Tag Library feature later in this chapter.

The Apply Source Formatting and Apply Source Formatting to Selection commands are examples of Dreamweaver commands that don’t display dialog boxes to gather the user’s selected parameters — because there are no parameters to set. To invoke the commands, choose Commands ➪ Apply Source Formatting or Commands ➪ Apply Source Formatting to Selection. The commands are applied immediately, with no confirmation or feedback indicating that they are complete. To verify their execution, you have to sneak a peek at your source code.

1013

33

Part VII

Extending Dreamweaver

The Clean Up HTML and Clean Up XHTML commands Dreamweaver tends to produce compact, uncluttered HTML/XHTML code, which is not always the case with other HTML/XHTML editors and hand-coded efforts. One of the most common problems is redundant tags, which can result when you select some text, change the font, change the font size, and, finally, change the font color. The resulting code is likely to resemble the following:

Bonanza!

The Clean Up HTML and Clean Up XHTML commands are custom made to consolidate redundant tags and to remove some of the code clutter that can accumulate during a page’s design. In all, you have seven different cleaning operations from which to choose. Note that the Clean Up HTML and Clean Up XHTML commands are applicable only to the current page and cannot be applied sitewide. XHTML syntax is much less forgiving than HTML; your XHTML code must be nearly perfect to work correctly. The Clean Up XHTML command fixes XHTML code syntax errors, lowercases all tag attributes, and adds (or reports) missing required tag attributes. To use the Clean Up HTML or Clean Up XHTML commands, follow these steps: 1. Load the desired HTML or XHTML document into your Dreamweaver workspace. 2. Choose Commands ➪ Clean Up HTML (for an HTML document) or Commands ➪ Clean Up XHTML (for an XHTML document). The Clean Up HTML/XHTML dialog box appears, as shown in Figure 33-1.

FIGURE 33-1 Reduce your page’s file size and make your HTML more readable with the Clean Up HTML/XHTML command.

3. Choose from these options in the dialog box:

n Remove: Empty Container Tags — Deletes empty tag pairs with no code between them (such as ). n Remove: Redundant Nested Tags — Eliminates superfluous tags that repeat the same code as the tags surrounding them, as shown in the following example:

1014

Customizing Dreamweaver

And the truth is plain to see.

n Remove: Non-Dreamweaver HTML Comments — Deletes any HTML comments that were not created by Dreamweaver to mark a Library or template item. n Remove: Dreamweaver Special Markup — Clears all Dreamweaver-specific comments, such as:

This code line inhibits the command name from being automatically displayed in the Commands menu list.

Creating a blank document Commands aren’t limited to working on the current document — you can use a command to read, modify, and even create new files. Any new file created using createDocument() or createXHTMLDocument() is an HTML or XHTML page based on the Default.html or Default.xhtml file found in the Dreamweaver 9\Configuration\DocumentTypes\NewDocuments folder. Occasionally, however, a command must make a new non-HTML/XHTML document, such as an XML or SMIL file or other file type that doesn’t use the ... structure. To accomplish this task,

1024

Customizing Dreamweaver

you first create an HTML file and then replace its entire contents with your own data — or nothing at all. The following custom function, developed by Andrew Wooldridge, makes and saves a new, blank text file: function doNew() { var newDOM = dreamweaver.createDocument(); var theDoc = newDOM.documentElement; theDoc.outerHTML = “.”; theDoc.innerHTML = “ “; dreamweaver.saveDocument(newDOM, ‘../../empty.txt’); }

Remember that all the Dreamweaver document functions — such as saveDocument() — use addresses relative to the file calling them. For example, if the doNew() function is included in a command and, therefore, stored in the Commands folder, the empty.txt document is saved two folders above the Commands folder in the Dreamweaver root directory, because the full path to it is Dreamweaver 9\Configuration\Commands.

Managing Menus and Keyboard Shortcuts Dreamweaver offers numerous ways to perform almost every task: through the Property inspector, context menus, keyboard shortcuts, and even entering code directly. However, in the search for ever-faster, more efficient ways of working, you may often find it desirable to take control of the menus and other command methods and make them work the way you and your team prefer them to work. If, for example, you insert a great number of AP elements and always define your links via the Property inspector, you are probably better off redefining Ctrl+L (Command+L) to Insert AP element, rather than its default, Make Link. Dreamweaver places all menus and keyboard shortcuts under your control. Not only can you add new items, but you can also rename menu items, change their keyboard shortcuts, determine when a menu item is active or dimmed — and even add entirely new menu strips. Moreover, all this functionality is available with the context menus as well. One file — menus.xml, found in the Dreamweaver 9\Configuration\Menus folder — is responsible for menu and keyboard shortcut setup. Although you have to edit the XML file by hand to reconfigure the menus, Dreamweaver includes a Keyboard Shortcut editor for modifying the keystroke commands. Details are in the “Using the Keyboard Shortcut Editor” section later in the chapter. Menu customization brings a whole new level of functionality to Dreamweaver. It’s entirely possible for a company to create custom subsets of a program for certain departments. For example, each of several departments in a large firm might be responsible for its own section of the Web site. A customized version of Dreamweaver could include a predefined site and disable the Define Site commands in the Site menu. It could also offer a specialized menu for calling up Help screens, tied to the standard F1 keyboard shortcut for Help. In addition to the fully open architecture of the menus.xml file, command menu items created by the History panel can be managed right in the Document window. Before you delve into the relatively complex structure of menus.xml, take a look at the Edit Command List feature.

1025

33

Part VII

Extending Dreamweaver

Handling History panel commands Whenever you save a series of History panel steps as a command, that command is instantly added to the bottom of the Commands menu list. Dreamweaver enables you to manage these custom added items — renaming them or deleting them — through the Edit Command List feature. To manage History panel recorded commands, follow these steps: 1. Choose Commands ➪ Edit Command List. The Edit Command List dialog box appears, as shown in Figure 33-3.

FIGURE 33-3 Manage your recorded commands through the Edit Command List dialog box.

2. To remove a command, select it and click Delete. 3. To rename a command, select it and enter the new name or alter the existing one.

Using the Keyboard Shortcut editor Whenever I’m learning a new program, one of the tasks I set for myself is to memorize the half-dozen or so essential keyboard shortcuts of the software. Keyboard shortcuts are terrific for boosting productivity — so terrific, in fact, that almost every program uses them. Although this is a good thing from a single-program user’s perspective, in reality no Web designer uses just one program, and having to remember the keyboard shortcuts for every program can be an absolute nightmare. To put the brakes on keyboard shortcut overload, Adobe has implemented a standard Keyboard Shortcut editor for its key Web products — Flash, Fireworks, and Dreamweaver. Where possible, common features share the same shortcut across the product line. For example, opening the Behaviors panel is accomplished with the same keyboard shortcut in Dreamweaver and Fireworks: Shift+F3. Dreamweaver also includes a set of shortcuts matching those from HomeSite and BBEdit to smooth your transition from those text-based editors. Best of all, you can personalize any existing set of shortcuts to work with the way you truly work best. To access the Keyboard Shortcut editor, shown in Figure 33-4, choose Edit ➪ Keyboard Shortcuts.

1026

Customizing Dreamweaver

FIGURE 33-4 Use the Keyboard Shortcut editor to establish the easiest-to-remember mnemonics for your keyboard shortcuts.

Rename set Export set as HTML Duplicate set

Delete set

The standard Keyboard Shortcut editor includes four standard sets of shortcuts: n BBEdit: Keyboard shortcut set matching those found in BBEdit. n Dreamweaver MX2004: This set uses the standard shortcuts found in Dreamweaver MX 2004. These additional shortcuts are not necessarily the same as those in the Adobe Standard set, because keystrokes may be added or modified for new features in the latest version. n HomeSite: Keyboard shortcut set matching those found in HomeSite. n Dreamweaver Standard: The default set of shortcuts incorporating common keyboard combinations in Dreamweaver, Fireworks, and Flash. To change from one set to another, open the Keyboard Shortcut editor and choose the desired set from the Current Set drop-down list. The changes take effect immediately upon closing the dialog box; you don’t have to relaunch Dreamweaver. The standard sets are locked and cannot be altered — you can only customize a copy of one of the standard sets. Dreamweaver provides all the controls to accomplish this on top of the Keyboard Shortcut editor. The four buttons are as follows: n Duplicate Set: Copies the current set (standard or custom) and appends the word copy. The duplicate set can be fully customized. n Rename Set: Renames the current shortcut set.

1027

33

Part VII

Extending Dreamweaver

n Export Set as HTML: Saves a list of the current set of keyboard shortcuts in an HTML format that can be viewed or printed in a browser. n Delete Set: Removes a keyboard shortcut set. When Delete Set is chosen, a list of all custom sets is displayed, and any set except the active one may be removed. To remove a sole custom set, select any of the standard shortcut sets prior to choosing Delete Set. Each command has up to two shortcuts assigned to it. This facility makes it possible to retain the originally assigned keyboard shortcut and to add a more personal one. To create a custom keyboard shortcut set, follow these steps: 1. Choose Edit ➪ Keyboard Shortcuts (Dreamweaver ➪ Keyboard Shortcuts) to open the editor. The editor might take a few moments to load your current keyboard shortcuts.

NOTE

From the Department of Pointless Nonsense, Irony Division: the Keyboard Shortcuts feature is one of the few commands without a keyboard shortcut.

2. From the Current Set drop-down list, select a standard keyboard shortcut set upon which to base your custom set. 3. Click the Duplicate Set button, type in an appropriate name for your custom shortcut set, and click OK. When the duplication is finished, select your new shortcut set from the Current Set list. 4. Choose the type of commands you want to modify from the Commands drop-down list. Dreamweaver has five different command types in Windows — Menu commands, Site panel, Code editing, Document editing, and Site window — and three under the Macintosh system — Menu commands, Code editing, and Document editing. 5. Select the specific command whose keyboard shortcut you want to modify. If you’ve chosen Menu or Site panel from the Commands list (Windows only), click the plus (+) sign next to the menu heading containing the command. The listing expands to show the first level of menu items. If the command you want to alter is contained within a submenu, click the plus (+) sign next to the submenu. Click the minus (–) sign to collapse an expanded listing. 6. With the desired command selected, click the Add (+) button in the Shortcuts section. The cursor moves into the Press Key field. 7. Press the keyboard combination you want to assign to the command. If Dreamweaver detects a conflict with an existing keyboard shortcut, an alert is displayed beneath the Press Key field telling you the command to which that shortcut is currently assigned. 8. Select Change to confirm your choice.

If the shortcut you selected is already in use, you can reassign it to your new choice. When you click Change under these circumstances, Dreamweaver brings up an alert dialog box warning you that the shortcut is currently assigned. It also tells you which command is using it, and asks if you want to reassign it to the command you are editing. To reassign the keystroke, click OK. To choose a new keyboard shortcut, click Cancel. If a command already has two shortcuts assigned to it, you select the one you want to change. 9. Click OK when you’re finished to save your keyboard shortcut set. The personalized keyboard shortcut files are stored in the Dreamweaver 9\Configuration\Menus\Custom Sets folder as XML files. To make a keyboard shortcut set available on another system, copy the appropriate XML file to the corresponding folder in the user’s Dreamweaver 9\Configuration\Menus\Custom Sets folder. For more details on the location of the user’s folders, see the “Multiuser System Customization” sidebar earlier in this chapter.

TIP

1028

Customizing Dreamweaver

Adjusting the menus.xml file When Dreamweaver is launched, the program reads the menus.xml file and builds the menu system. You can even customize menus.xml and reload the file from within Dreamweaver to instantly update your menu and shortcuts. The key, of course, is editing the XML file. The syntax for menus.xml is quite complex. Dreamweaver ignores any syntactically incorrect entries and disables their corresponding menu items. So, take great care when you edit menus.xml to use proper syntax, and make sure you create a backup of the file before you begin editing.

CAUTION

The typical procedure for changing an existing menu item or shortcut is to open the file in a text editor (after backing up the original) and make the necessary changes. When adding menus or menu items, follow the file’s syntax exactly, as described in the following sections.

Generic shortcuts Although Dreamweaver now provides a user interface for editing the keyboard shortcuts, sometimes power-users must go to the source for major modifications — and the source for shortcuts is menus.xml. The menus.xml file is divided into two main sections: and . The divisions are, as you might suspect, a list of keyboard shortcuts. The areas are concerned with the various menu bars — in the main Document window, in the Site panel (Windows only), and in the numerous context menus. and share several characteristics. They both follow the same basic structure:

other shortcut items...



other menuitem items...

other menu items...

Shortcuts for menu items are primarily defined within the code; the is mainly concerned with those shortcuts that do not have a menu item associated with them, such as moving from one word to another. By default, Dreamweaver defines six sections: DWMainWindow for the Document window menu, DWMainSite for the Site panel menu (Windows only), DWHTMLContext for the Code inspector/Code view context menu, DWServerBehaviorContext for the Server Behaviors panel context menu, DWDataBindingContext for the Bindings panel context menu, and DWServerComponentContext for the Components panel context menu. The key difference between the and the sections is that although you can define new menu items or change existing ones in the portion of the code, you can only alter existing shortcuts — you cannot add new shortcuts.

NOTE

Each tag has one required attribute, the ID. The ID refers to a specific window or panel and must be unique within the section. The same ID is repeated in the

1029

33

Part VII

Extending Dreamweaver

section to refer to the same window or panel. For example, the Document window ID is DWMainWindow, whereas the one for the context menu of the Server Behaviors panel is DWServerBehaviorContext. The tag takes one optional attribute, platform, which must be set to either win or mac, for Windows and Macintosh systems, respectively. (Note that in syntax statements, optional attributes are enclosed in brackets.) If no platform attribute is listed, the described applies to both platforms. Here, for example, is the beginning of the definition for the Files panel, which only appears in the Windows version of the software:

A separate tag exists for every keystroke defined in the . The tag defines the key used, the tag’s ID, the command or file to be executed when the keyboard shortcut is pressed, and the applicable platform, if any. Shortcuts can be defined for single special keys or key combinations using modifiers. The special keys are as follows: n n n n

F1 through F12 PgDn, PgUp, Home, End Ins, Del, BkSp, Space Esc and Tab

Modifiers can be used in combination with standard keys, with special keys, or by themselves. A combination keyboard shortcut is indicated with a plus sign between keys. Available modifiers include those described in Table 33-1. TABLE 33-1

Dreamweaver Shortcut Modifier Keys Key

Example

Use

Alt or Opt

Alt+V; Option+V

Indicates the Alt (Windows) or Option (Macintosh) key modifier

Cmd

Command+S

Indicates the Command (Macintosh) key modifier

Ctrl

Ctrl+U

Indicates the Ctrl (Windows) key modifier

Shift

Shift+F1

Indicates the Shift key on both platforms

You can also combine multiple modifiers, as in this example: Command+Shift+Z. The format of the tag is identical to that of the tag, as described in the following section.

Menubar definitions Each section of the menus.xml file describes a different menu strip, either on a window or on the context menu associated with a panel. Nested within the tag is a series of tags, each detailing a drop-down menu. The individual menu items are defined in the tags contained within each set of ... tags. Here, for example, is the context menu for the HTML Styles panel (I’ve abbreviated the complete tag for clarity):



1030

Customizing Dreamweaver





The and tags are alike in that they both require a name — which is what appears in the menu system — and an ID. The ID must be unique within the structure to avoid conflicts. If a conflict is found (that is, if one item has the same ID as another), the first item in the XML file is recognized, and the second item is ignored.

NOTE

You can put a dividing line between your menu items by including a tag between any two tags. (idname is any legal, unique XML

name string.)

Numerous other attributes exist for the tag. The required attributes are name, id, and either file or command, as marked with an asterisk in Table 33-2. TABLE 33-2

Menuitem Tag Attributes Attribute

Possible Value

Description

name*

Any menu name

The name of the menu item as it appears on the menu. An underscore character causes the following letter to be underlined for Windows’ shortcuts — for example, _Frames becomes Frames.

id*

Any unique name

The identifying term for the menu item.

key

Any special key or keyboard key plus modifier(s)

The keyboard shortcut used to execute the command.

platform

win or mac

The operating system valid for the current menu item. If the platform parameter is omitted, the menu item is applicable for both systems.

enabled

JavaScript function

If present, governs whether a menu item is active (the function returns true) or dimmed (the function returns false). Including enabled=true ensures that the function is always available.

command* (required if file is not used)

JavaScript function

Executed when the menu item is selected. This inline JavaScript function capability is used for simple functions.

file* (required if command is not used)

Path to a JavaScript file

The JavaScript file is executed when the menu item is selected; the path is relative to the Configuration folder.

checked

JavaScript function

Displays a checkmark next to the menu item if the function returns true.

dynamic

N/A

Specifies that the menu item is set dynamically by the getDynamicContent() function, which resides in the Menu Commands file specified by the file attribute.

1031

33

Part VII

Extending Dreamweaver

The menus.xml file is quite extensive. You can find the main menu for Dreamweaver — the one you most likely want to modify — by searching for the second instance of its ID, DWMainWindow. The first instance is used by the corresponding tag.

TIP

You can create submenus by nesting one set of tags within another. The following example is a simplified look at the File ➪ Import commands, as structured in menus.xml:

other menu items...



other menu items...

Note how the tag defining the Import submenu is nested within the tag that defines the File menu.

Building menu commands When examining the menus.xml file, notice that many menu items have JavaScript functions written right into the tag, such as this one for File ➪ New:

When the user selects File ➪ New, Dreamweaver executes the API function dw.newDocument() in what is referred to as a menu command. Menu commands are used to specify the action of every menu item; what makes them unique is that you can use them to create and activate dynamic menus. Dynamic menus update according to user selections; the Preview in Browser list is a dynamic menu. A menu command, like most of the other Dreamweaver extensions, is a combination of HTML and JavaScript. If the menu command is extensive and cannot be referenced as one or two functions directly in the menus.xml file, it is contained in an HTML file, stored in the Dreamweaver 9\Configuration\Menus folder. Menu commands can even use a dialog box, such as standard commands for accepting user input.

TIP

You can find many examples of menu commands, written by the Dreamweaver engineers, in the Dreamweaver 9\Configuration\Menus\Mm folder.

Menu commands have access to all the Dreamweaver API functions and a few of their own. None of the seven menu command API functions, listed in Table 33-3, is required, and three are automatically called when the menu command is executed.

1032

Customizing Dreamweaver

TABLE 33-3

Command Menu API Functions Function

Returns

Description

canAcceptCommand()

Boolean (true or false)

Determines whether the menu item is active or dimmed

commandButtons()

An array of labels and functions, separated by commas

Sets the name and effect of buttons on the dialog box

getDynamicContent()

An array of menu item names and unique IDs, separated by a semicolon

Sets the current listing for a menu

isCommandChecked()

Boolean

Adds a checkmark next to the item if true is returned

receiveArguments()

Nothing

Handles any arguments passed by the tag

setMenuText()

A text string

Sets the name of the menu item according to the given function; not to be used in conjunction with getDynamicContent()

windowDimensions()

Width,Height (in pixels)

Determines the dimensions of the Parameters dialog box, like windowDimensions(300,500)

Working with Custom Tags With the advent of XML — in which no standard tags exist — the capability to handle custom tags is essential in a Web authoring tool. Dreamweaver incorporates this capability through its third-party tag feature. After you’ve defined a third-party tag, Dreamweaver displays it in the Document window by highlighting its content, inserting a user-defined icon, or doing neither depending on the Preferences selected and the attributes assigned. Third-party tags are easily selected through the Tag Selector below the Document window; therefore, they are easy to cut, copy and paste, or otherwise manipulate. Perhaps most important, after a third-party tag is defined, you can apply a custom Property inspector that enables tag attributes to be entered in a standardized user interface. Third-party tags can be defined directly within Dreamweaver. Just as object files use HTML to structure HTML code for easy insertion, Dreamweaver uses XML to make an XML definition for the custom tag. A custom tag declaration consists solely of one tag, , with up to seven attributes. The following list describes all of the tag’s legal attributes: n tag_name — Defines the name of the tag as used in the markup. Any valid name — no spaces or special characters are allowed — is possible. A tag with the attribute tag_name=”invoice” is entered in the document as . n tag_type — Determines whether the tag has a closing tag (nonempty) and is thus capable of enclosing content or if the tag describes the content itself (empty). For example, the tag could have a tag_type=”nonempty” because all the content is between and .

1033

33

Part VII

Extending Dreamweaver

n render_contents — Sets whether the content of a non-empty type tag is displayed. The render_contents attribute value is either true or false; if false, the tag’s icon is displayed instead of the contents. n content_model — Establishes valid placement and content for the tag in the document. The possible options are as follows: n block_model — Tags defined with content_model=”block_model” appear only in the section of a document and contain block-level HTML tags, such as

, , , and . n head_model — Defines a tag that appears in the section and can contain text, for example: content_model=”head_model”.

n

n n

n

n

n n n

n marker_model — You can place tags with the attribute content_model=marker_model anywhere in the document with no restrictions on content. The marker_model value is most often used for inline tags that are placed within a paragraph or division. n script_model — Like the marker_model tag, script_model tags can be placed in either the or section. All content within a script_model tag is ignored by Dreamweaver. This feature enables server-specific scripts to be included without alteration. start_string — The initial delimiter for a custom string-delimited tag; start_string and end_string must both be defined if one is declared. Lasso tags, for example, use a start_string of a left bracket, ([). end_string — The closing delimiter for a custom string-delimited tag. The end_string for a Lasso tag is the right bracket, (]). detect_in_attribute — A Boolean value that determines whether Dreamweaver should ignore string-delimited tags used as attributes in other tags. The default is false, but for most string-delimited functions, the detect_in_attribute value should be set to true. parse_attributes — A Boolean value that determines whether Dreamweaver should inspect and parse the attributes within string-delimited tags. By default, Dreamweaver parses all attributes; set parse_attribute to false to force Dreamweaver to ignore the attributes. icon — Empty tags or non-empty custom tags with render_content disabled require a GIF file to act as an icon in the Document window. The icon attribute should be set to any valid URL, relative or absolute (as in icon=”images/invoice.gif”). icon_width — Sets the width, in pixels, of the icon used to represent the tag. The value can be any positive integer. icon_height — Sets the height, in pixels, of the icon used to represent the tag. The value can be any positive integer. is_visual — Sets whether the tag is rendered in the Design view; either a true or false value is acceptable.

Here’s the complete code for a sample custom tag, the Template Expressions tag (which, although created by Adobe, is technically a third-party tag):

Figure 33-5 shows an example of the Template Expressions custom tags; the page is set up so that the items on the menu can be altered with template expressions.

1034

Customizing Dreamweaver

FIGURE 33-5 Third-party tags, such as these representing template expressions, can be displayed — and manipulated — in Design view.

If the content is to be rendered for a custom tag, you can easily view it in the Document window by enabling the Third-Party Tags Highlighting option in the Highlighting panel of the Preferences dialog box. Make sure that View ➪ Visual Aids ➪ Invisible Elements is enabled.

TIP

After a custom tag is defined, the definition is saved in an XML file in the ThirdPartyTags folder, in Dreamweaver’s Configuration folder. If you are establishing a number of custom tags, you can place all the definitions in the same file. Adobe refers to this as the Tag DB or Database.

Customizing Property Inspectors Property inspectors are used throughout Dreamweaver to display the current attributes of many different types of tags: text, images, AP elements, plugins, and so on. Not only do Property inspectors make it easy to see the particulars for an object; they make it a snap to modify those parameters. With the inclusion of custom tags in Dreamweaver, the capability to add custom Property inspectors is a natural parallel. Moreover, you can create custom Property inspectors for existing tags, and the custom Property inspectors are displayed in place of the built-in Property inspectors. Like objects, commands, and behaviors, custom Property inspectors are composed of HTML and JavaScript; the Property inspector HTML file itself is stored in the Dreamweaver 9\Configuration\Inspectors folder. However, the layout of the Property inspector is far more restrictive than that of the other Dreamweaver extensions. The dialog box for an object, command, or behavior can be any size or shape desired — any custom Property inspector must fit the standard Property inspector dimensions and design. Because of the precise positioning necessary to insert parameter form items such as text boxes and drop-down menu lists, AP elements are used extensively to create the layout.

1035

33

Part VII

Extending Dreamweaver

Very elaborate Property inspectors are possible. The FlashBang! Property inspector, created by Joseph Lowery and Edoardo Zubler, is shown in Figure 33-6. Property inspectors, like other extension types, can also incorporate CSS styles, Flash movies, and Shockwave files. FIGURE 33-6 The code for some custom Property inspectors, such as this one from FlashBang!, takes advantage of Dreamweaver’s AP element and CSS styles support.

Coding a Property inspector Like many of the other standard extension files, most of the Property inspector files that ship with Dreamweaver are composed of an HTML file that calls a separate JavaScript file. It is entirely possible, however, to combine HTML and JavaScript into a single file. No matter how it’s structured, a custom Property inspector HTML file requires the following four key elements: n An initial DTD (Document Type Definition) line for custom Property inspectors:

n An HTML comment line immediately preceding the opening tag that identifies which tag the Property inspector is for; here’s the HTML comment line for a META tag Property inspector:

(The last three values of the selection attribute — hline, vline, and serverModel — are all optional.) For example, the Property inspector for the tag (a element) is defined as follows:

The individual sections of the definition are as follows: n tag — The name of the tag for which the Property inspector is intended. Although it’s not mandatory, the tag name is customarily uppercased. The tag ID can also be one of three keywords: *COMMENT*, when a comment class tag is indicated; *LOCKED*, when a locked region is to be inspected; or *ASP*, for all ASP elements.

NOTE

The asterisks on either side of the tag keywords are mandatory.

n priority — The priority of a Property inspector is provided as a number from 1 to 10. The highest priority, 10, means that this Property inspector takes precedence over any other possible Property inspectors. The lowest priority, 1, marks the Property inspector as the one to use when no other Property inspector is available. You can find an example of how priority is used in the tag and the Description and Keywords objects. The Property inspectors for Description and Keywords have a higher priority (6) than the one for the basic tag (5), which enables those inspectors to be shown initially if the proper criteria are met; if the criteria are not met, the Property inspector for the tag is displayed.

NOTE

1037

33

Part VII

Extending Dreamweaver

n selection — Depending on the current selection, the cursor is either within a particular tag or exactly enclosing it. The selection attribute is set to within or exact, according to the condition under which the Property inspector should be displayed. n hline — Inserts a 1-pixel horizontal gray line (see Figure 33-7) dividing the upper and lower halves of the expanded Property inspector. n vline — Places a 1-pixel vertical gray line (see Figure 33-7) between the tag’s name field and the other properties on the upper half of the Property inspector. FIGURE 33-7 The Property inspector for the tag uses both the hline and vline attributes.

vline

hline

The canInspectSelection() function To control the circumstances under which your custom Property inspector is displayed, use the canInspectSelection() function. Like canAcceptBehavior() and canAcceptCommand() for behaviors and commands, respectively, if canInspectSelection() returns true, the custom Property inspector is shown; if it returns false, the Property inspector is not shown. As noted earlier, the canInspectSelection() function is mandatory. If no conditions exist under which the Property inspector should not be displayed, use the following code: function canInspectSelection() { return true; }

Access to several of the standard Dreamweaver elements’ Property inspector files is restricted by the canInspectSelection() function to specific tags. In the following example, from the Description object, the current selection is examined to see if a tag is selected, and the name attribute is set to description: function canInspectSelection() { var dom = dw.getDocumentDOM(); var metaObj = dom.getSelectedNode();

1038

Customizing Dreamweaver

if (!metaObj || !metaObj.getAttribute) return false; return (metaObj.tagName && metaObj.tagName == “META” && metaObj.getTranslatedAttribute(“name”) && metaObj.getTranslatedAttribute(“name”).toLowerCase()==”description”); }

The inspectSelection() function The inspectSelection() function is the workhorse of the custom Property inspector code and is responsible for pulling the information from the selected tag for display in the various Property inspector fields. Depending on the code design, the inspectSelection() function can also be used to update the HTML code when the attribute values are modified in the Property inspector. Here’s an excerpt of the inspectSelection() function from the Link Property inspector file: function inspectSelection() { TEXT_HREF = findObject(“Href”); ... if (linkObj.getAttribute(“href”)) TEXT_HREF.value = linkObj.getAttribute(“href”); else TEXT_HREF.value = “”; ... }

In this example, if an attribute (href) exists, its value is assigned to the Property inspector’s appropriate text box value (TEXT_HREF.value). The remainder of the inspectSelection() function for the tag consists of a series of statements such as those shown in the sample code. You can design a Property inspector that displays a different interface depending on whether or not it is expanded, as the Keywords Property inspector does. If an inspector is not expanded, the argument(0) property is set to the value min; when it is expanded, argument(0) is equal to the value max.

TIP

Many Property inspectors update their HTML tags when a change occurs in one of the input boxes. No real standard method exists to accomplish this, due to the many possible variations with Property inspectors. However, one of the most commonly used events is onBlur(), as in the following example, taken from the Keywords Property inspector file: var minText = ‘’

The setMetaTag() function that is called is a local one that assigns whatever is currently in the textarea of the Property inspector to the content attribute.

Designing a Property inspector All the attributes for a Property inspector must fit into a tightly designed space. Although it’s helpful to look at examples found in the Inspectors folder, many of the standard Property inspectors are built in to the core functionality of the program and are not immediately accessible on the design level. The following specifications and tips should make it easier to design your own custom Property inspectors:

1039

33

Part VII

Extending Dreamweaver

n An expanded Property inspector is 100 pixels high: 50 pixels for the top portion and 49 pixels for the bottom portion (the dividing line between the two is 1-pixel high). n If the hline attribute is specified in the Property inspector definition, a 1-pixel–high line is drawn the entire width of the inspector, 51 pixels down from the top (reducing the bottom portion’s height to 49 pixels). n If the vline attribute is specified, a single-pixel line is drawn across the top half of the Property inspector, 118 pixels from the left. n The image placed on the upper-left corner of the Property inspector is generally sized at 36 pixels square and placed 3 pixels from the top and 2 pixels from the left. Although you are not required to keep this size image — or its placement — following these guidelines helps make your custom Property inspectors resemble the standard Dreamweaver ones. n It’s a good idea to lay out your Property inspector with the View ➪ Visual Aids ➪ Invisible Elements option disabled. The small icons that indicate AP elements can alter the perceived spacing. n Keep the AP Elements panel visible. Many custom Property inspectors use multiple AP elements to position the elements exactly and the AP Elements panel makes selecting individual AP elements for adjustment a snap. n Use nested AP elements to position and group associated items in the Property inspector. Almost all the form objects for user input in Property inspectors, such as text boxes and drop-down lists, are identified by labels. Placing both the label and text boxes in their own AP elements, while grouping them under one parent AP element, provides maximum flexibility and ease of placement. n Apply CSS styles within the Property inspector to easily manage font sizes and design your Property inspector in a WYSIWYG environment.

Making Custom Floating Panels Property inspectors are an excellent way to manage the attributes of most elements in a single, consistent user interface. The Property inspector user interface, however, is not the best solution for all situations. Recognizing this, the Adobe engineers have added another extension type for Dreamweaver: floating panels. A floating panel is a cross between a Property inspector and a command. Like Property inspectors, floating panels can stay on the screen while you work on the Web page; like commands, floating panels are not restricted to a set size and shape. Custom floating panels have the same basic interface as standard Dreamweaver panels. Any floating panel can be resized or grouped with other floating panels, standard or custom. After it is grouped, a custom floating panel also has a tab that, when selected, brings the floating-panel interface to the front. A couple of noteworthy differences exist between built-in and custom floating panels: n Built-in floating panel tabs can display names and icons; custom floating panel tabs can only display names. n Built-in floating panels can be assigned a minimum size; custom floating panels cannot (that is, the user can shrink them down to about 100 x 100 pixels). Floating panels, like most other extensions, are a combination of HTML and JavaScript. HTML is the main file that is called; it provides the user interface via an HTML form. JavaScript provides the functionality from the of the HTML page. Like Property inspectors, floating panels have their own DTD that you must include as the first line in your custom floating panel files: .

NOTE 1040

Customizing Dreamweaver

Floating panels are stored in the Dreamweaver 9\Configuration\Floaters folder. However, unlike commands or objects, you can’t just save your custom floating panel in a particular folder to make it accessible. You must call a function that displays the floating panel, either dw.setFloaterVisibility(floaterName,true) or dw.toggleFloater(floaterName). Most often, these functions are called from a tag in the menus.xml file, like the following custom floating panel:

The checked attribute ensures that a checkmark is displayed next to the menu item if the floating panel is visible. When naming a custom floating panel, be sure to avoid names reserved for Dreamweaver’s built-in elements: assets, behaviors, codesnippet, CSS styles, dataSource, documenttype, frames, helpbook, HTML, insertbar, AP elements, library, objects, or history properties, reference, samplecontent, serverBehavior, serverFormat, serverModel, site, taglibrary, site files, site map, templates, timelines, timelines, or toolbar.

CAUTION

As indicated in the preceding paragraphs, floating panels have their own API functions, and several methods of the Dreamweaver object are applicable. The floating panel API functions, none of which is required, are described in Table 33-4. TABLE 33-4

Floating Panel API Functions Function

Returns

Use

displayHelp()

Nothing

Specifies whether a Help button should appear beneath the OK and Cancel buttons

documentEdited()

Nothing

Executes after the current document has been edited

getDockingSide()

A string containing left, right, top, and/or bottom

For Dreamweaver 9 (Windows only) Specifies where a floating panel can dock

initialPosition (platform)

A string in the format left,top

initialTabs()

A string in the format Indicates what other floating panels are grouped with the floatingPanel1, current floating panel when it first appears floatingPanel2,. . .

isATarget()

Boolean

For Dreamweaver 9 (Windows only) Specifies if other panels can dock to this panel

IsAvailable InCodeView()

Boolean

Determines if the floating panel is enabled when Code view is active

isResizable

Boolean

Specifies whether the floating panel can be resized by the user

selectionChanged()

Nothing

Executes after the current selection has been altered

Sets the position of the floating panel onscreen when it is first called; if left onscreen when Dreamweaver quits, it reopens in the last location

1041

33

Part VII

Extending Dreamweaver

Adobe strongly cautions programmers against using documentEdited() and selectionChanged() unless these functions are absolutely necessary. Because they constantly monitor the document, both functions can have an adverse effect on performance if implemented. Adobe suggests that programmers incorporate the setTimeout() method to temporarily pause these functions so that the user can continue to interact with the program.

CAUTION

Within the Dreamweaver API are two pairs of methods and a single function that relate to floating panels as follows: n getHideAllFloaters() — Reads the state of the Show/Hide Floating Panel menu option to determine if all floating panels should be hidden (true) or shown (false) n setHideAllFloaters() — Sets the Show/Hide Floating panel to a particular state, to Hide (true) or Show (false) n getFloaterVisibility(floaterName) — Reads whether the given floating panel is currently displayed and frontmost (true) or hidden (false) n setFloaterVisibility(floaterName,isVisible) — Brings the named floating panel forward if the isVisible argument is true n toggleFloater(floaterName) — Toggles the visibility state of the given floating panel between hiding and bringing to the front Floating panels have a great deal of potential with their flexible interface and constant onscreen presence. The example shown in Figure 33-8, and built by WebAssist, manages the global settings for a shopping cart on three different tabs. FIGURE 33-8 The custom floater, built by WebAssist, controls global settings as well as merchandising rules for a shopping cart extension, WA eCart.

Developing Translators For any markup tag to be depicted in the Document window — whether it’s for bold or a custom thirdparty tag such as Tango’s — it must be translated. Dreamweaver’s built-in rendering system translates all the standard HTML code, along with a few special custom tags such as those for ASP and ColdFusion. However, to display any other custom tags, or those that perform special functions such as server-side includes, the tag developer must build a custom translator.

1042

Customizing Dreamweaver

As part of its expansion efforts, Dreamweaver supports custom translators. This enhancement enables programs that output nonstandard HTML to be displayed onscreen integrated with the regular code. One of Dreamweaver’s main claims to fame is its capability to accept code without rewriting it. With Dreamweaver translators, you can visually insert, show, and edit your custom code. Here’s a brief overview of how translators work: 1. When Dreamweaver starts, all the properly coded translators in the Dreamweaver 9\Configuration\Translators folder are initialized. 2. If a document is loaded with nonstandard HTML, the code is checked against the installed translators. 3. The translators are enabled.

NOTE

With the exception of the SSI translator, all translators are automatically active all the time — no preference setting determines their availability.

4. The code is processed with the translator and temporarily converted to a format acceptable to Dreamweaver. 5. Dreamweaver renders the code onscreen. 6. If a change is made to the page, Dreamweaver retranslates the document and refreshes the screen. 7. When the page is saved, the temporary translation is discarded, and the original code, with any modifications, is stored.

Developers continue to break new ground with the use of translators. Some translators that have been developed so far include those for the following: n Server-side includes: Standard with Dreamweaver, the SSI translator effortlessly inserts, at design time, files that you normally don’t see until delivered by the Web server. (To learn more about SSI, see Chapter 28.) n XSSI: The Extended Server-Side Include (XSSI) extension, developed by Webmonkey authors Alx Ladygo, Nadav Savio, and Taylor for Adobe, includes a translator that brings the Apache-served code right into the Document window. n Tango: Developed by Pervasive Software, the Tango translator compensates for differences between database-oriented code and standard HTML. Additionally, Tango includes a manually controlled Sample Data translator that enables the Web designer to view the page complete with an example database.

Translator functions Like other Dreamweaver extensions, such as behaviors and commands, translators are HTML files with JavaScript. Translators have no user interface. Other than deciding when to invoke it, you have no parameters to set or options from which to choose. All the pertinent code is in a script located in the of the translator, which, along with any necessary support routines, includes two essential JavaScript functions: getTranslatorInfo() and translateMarkup(). Any other Dreamweaver JavaScript API functions not specific to behaviors can be used in a translator as well. Because of the limitations of JavaScript, much of the heart of custom translation is handled by specially written C-level extensions. These compiled code libraries enhance Dreamweaver’s capabilities so that new data types can be integrated. C-level extensions are covered in the “Extending C-Level Libraries” section later in this chapter.

NOTE

1043

33

Part VII

Extending Dreamweaver

The getTranslatorInfo() function The getTranslatorInfo() function simply sets up and returns an array of text strings that are read by Dreamweaver during initialization. The structure of the array is relatively rigid. The number of array elements is specified when the Array variable is declared, and a particular text string must correspond to the proper array element. The array order is as follows: n translatorClass: The translator’s unique name used in JavaScript functions. The name has to begin with a letter and can contain alphanumeric characters as well as hyphens or underscores. n title: The title listed in the menu and the Translation category. This text string can be no longer than 40 characters. n nExtensions: The number of file extensions, such as .cfml, to follow. This declaration tells Dreamweaver how to read the next portion of the array. If this value is set to 0, all files are acceptable. n extension: The actual file extension without the leading period. n nRegExps: The number of regular expressions to be declared. Should this value be equal to 0, the array is closed. n RegExps: The regular expression to be searched for by Dreamweaver. n runDefault: Specifies when the translator executes (always, never, or conditionally). The number of array elements — and thus, the detail of the function — depends entirely on the translator. Here, for example, is the code for getTranslatorInfo() from Live Picture’s translator, where a file must have a particular tag to be translated: function getTranslatorInfo(){ returnArray = new Array( 5 ); returnArray[0] = “FPX”; // translatorClass returnArray[1] = “Flashpix Image Translator”; // title returnArray[2] = “0”; // number of extensions returnArray[3] = “1”; // number of expressions returnArray[4] = “

Individual Price $@@(priceVar)@@.00
Buy 5 for the price of 3! Quantity Price $@@(priceVar * 3)@@.00 6, then the kids are in ; school]]>

Communication between XML and HTML is greatly eased because large blocks of data can be passed in this fashion. n Document type declarations: Because every XML document is capable of containing its own set of custom tags, a method for defining these tags must exist. Although a discussion of the formats of such document type declarations is beyond the scope of this book, it’s helpful to know that such declarations can be made for elements, attributes, character entities, and notations. Notations refer to external binary data, such as GIFs, that are passed through the XML parser to the application. XML documents may begin with an XML declaration that specifies the version of XML being used. The XML declaration for a document compliant with the 1.0 specification looks like this:

A much more detailed document type declaration (DTD), in which each tag and attribute is described in SGML, is also possible. XML documents that include these types of DTDs are labeled valid XML documents. Other documents that respect the rules of XML regarding nesting of tags and other matters, but don’t include DTDs for the elements, are known as well-formed XML. Dreamweaver exports well-formed XML documents but can import either well-formed or valid XML.

Exporting XML How do you make an XML page? You can choose File ➪ New and select XML from the Basic category, or you can convert an existing document into XML format with one command. Currently, Dreamweaver creates its XML pages based on a template’s editable regions. With this approach, the true content of a page — what distinguishes it from all other pages of the same type — can be separated and applied independently of the original Web page. In other words, after the XML information is gathered from a Web page, it can be imported into any other application to be displayed, read, spoken, translated, or acted upon.

CROSS-REF

To get a better idea of how to use XML, you need to understand Dreamweaver templates, which are discussed in Chapter 28.

Dreamweaver templates are composed of locked and editable regions; the locked regions are repeated for each page created from the template, whereas the content in the editable regions is added per page. The connection between XML and templates is similar to the relationship between a database form and its data. In a database, each field has a unique name, such as LastName, FirstName, and so on. When you create a database form to present the data, the placeholders for the data use the same field names. Then, when data

987

32

Part VI

Enhancing Productivity and Web Site Management

from one record flows into the form, the information from the field goes into the areas with the corresponding field names. Likewise, each editable region has a unique name — in essence, a field name. The content within the editable region is the field’s data. When the template data is exported as an XML file, the name of the editable region is converted to an XML tag that surrounds its data. For example, Figure 32-1 shows a Dreamweaver template for a purchase order. On the left are the headings (To, Company, Address, and so on) for the information in a locked area, whereas the specific shipping data (on the right) resides in a series of editable regions, each with its own name. FIGURE 32-1 Dreamweaver creates XML pages based on templates and editable regions. This template is now ready to be exported as an XML file.

When exported as XML by Dreamweaver, the resulting XML file looks like the following:

Purchase Order ]]>

Anytown, USA]]>



988

Integrating with XML and XSLT

Note several important items about the XML file. First, notice the use of self-evident labels for each of the tags, such as and ; such names make it easy to understand an XML file. Even the one tag not based on a user-defined name, , is straightforward. Second, all the data included in the XML tags is marked as a CDATA area; this ensures that the information is conveyed intact, just as it was entered. Finally, if you look at the tag data, you see that even HTML tags (here, a
tag) are included in the CDATA blocks. This practice enables you to carry over basic formatting from one page to the next. You can avoid this by designating just the inner content — without any of the formatting tags — as an editable region. Dreamweaver can create one of two different types of XML tags during its export operation. The first is referred to as Dreamweaver Standard XML and uses an tag with a name attribute set to the editable region’s name. For example, if the editable region is named ShipVia, the Dreamweaver Standard tag is Content

The Dreamweaver Standard XML file has one other distinguishing characteristic. The XML file is saved with a reference to the defining Dreamweaver template, like this:

When importing a Dreamweaver Standard XML file, if the specified template cannot be found, a dialog box appears asking that you select another template. The other option is to use what Dreamweaver refers to as Editable Region Name tags. This method uses the editable region names themselves as tags. In the case of the editable region name ShipVia, the tag pair under this method is .... To create an XML file from within Dreamweaver, follow these steps: 1. Open a Dreamweaver document based on a template that has at least one editable region. 2. Choose File ➪ Export ➪ Export Editable Regions As XML. The Export Template Data as XML dialog box opens, as shown in Figure 32-2.

FIGURE 32-2 You can convert any template-based page to an XML document by using the Export Template Data as XML dialog box.

3. Choose the form at for the XML tags by selecting one of the Notation options:

n Use Standard Dreamweaver XML Tags: Select this option to produce tags with name attributes set to the names of the editable regions. n Use Editable Region Names As XML Tags: Select this option to produce XML tags that use the editable region names directly. Selecting either option displays sample tags in the Sample area of the dialog box.

989

32

Part VI

Enhancing Productivity and Web Site Management

4. Click OK when you’re finished. An Export Editable Regions as XML Save File dialog box appears. 5. Enter the path and name of the XML file you want to save in the File Name text box. Click Save when you’re finished.

Importing XML As part of Roundtrip XML, Dreamweaver includes an Import XML command. Like the Export XML command, Import XML works with Dreamweaver templates. The content information in the XML document fills out the editable regions in the template, much as data fills out a form in a database. With this import capability, you can independently create and store content in an XML file and then, if you want to publish the page to the Web, simply import it into the Dreamweaver template. To be imported, XML files must follow one of the two structures used when exporting a template to XML: Standard Dreamweaver XML or Editable Region Names used as XML tags. Although it’s a matter of personal preference, I find the Editable Region Names format to be easier to read and, in general, simpler to work with. When you’re importing XML files, make sure that the XML files that you’re importing have the necessary template declarations in order for Dreamweaver to find the appropriate template to format the incoming data.

NOTE

How do you create a file from the XML? Naturally, you could open a template for your XML document and fill in the data by hand — but that, in a sense, defeats the purpose of automating your workflow via XML. A more efficient scenario is to use a database to accept and store content; the database entry form is easily accessible over a network or over the Internet. A report, generated by the database application, blends the content data and the XML structure, resulting in an XML file to be imported into Dreamweaver. To import an XML file into a Dreamweaver template, follow these steps: 1. If desired, open a file based on a Dreamweaver template. 2. Choose File ➪ Import XML into Template. The Import XML dialog box opens.

CAUTION

Any existing information in the Dreamweaver document in the editable regions is replaced by the information in the corresponding tags of the XML document.

3. Select an XML file from the Import XML dialog box. 4. Select Open when you’re finished.

The XML file is imported into Dreamweaver, and the editable region placeholder names are replaced with the data in the XML document.

Building Your Own XML Files Dreamweaver now supports editing XML files directly in the Dreamweaver interface. No Design view is available, but Dreamweaver code coloring and syntax checking can make writing your own XML files much easier than writing them in a standard text editor.

990

Integrating with XML and XSLT

In order to take full advantage of Dreamweaver’s code-editing features, you use tag libraries to set up all the tags you need to create your XML files. If you use the previously discussed template file as an example, you can define a set of XML tags for describing your purchase order details.

CROSS-REF

To find out how to define your own tag libraries, see the section on the Tag Library Editor in Chapter 33.

Figure 32-3 shows the XML tags defined for the Purchase Order XML files. You can even specify attributes for each of the tags. Now if you type supplies the closing tag. FIGURE 32-3 With Dreamweaver’s Tag Library Editor, you can completely customize the crafting of new XML files.

Styling with XSL Whereas HTML code has some degree of built-in styling — browsers render content enclosed with

tags much differently from what’s within an tag — XML has none: it’s all just data. The Extensible Stylesheet Language (XSL) specification developed the W3C is intended to give designers the power to shape XML data. In fact, XSL has the potential to go beyond styling to actual transformation; functions within XSL can, for example, sort the XML data it is passed. Dreamweaver embraces XSL in a major way. Dreamweaver has the power to create XSL documents to fit a variety of situations, including both server-side and client-side options. This facility opens a whole new world of possibilities for Dreamweaver users. For example, designers can include information from RSS (Really Simple Syndication) feeds right in their Web pages — styled to fit into the look-and-feel of their site — through a very straightforward process. For intranet developers, XML reports, like those generated by Dreamweaver’s own Reports system, can be presented in a suitable fashion.

991

32

Part VI

Enhancing Productivity and Web Site Management

XSL is actually a family of W3C specifications. In addition to the XSL standard, a separate specification covers XSLT, short for XSL Transformations. Many of the Dreamweaver XSL features involve XSLT functions that convert XML to HTML and CSS. Another key component under the XSL umbrella is the XML Path Language or XPath. XPath is an expression language that allows the XML data to be selectively presented; XPath powers Dreamweaver features like the XSL Repeat Region. Dreamweaver creates two different types of XSL content: a full XSLT page that displays HTML and transformed XML data together, or an XSLT fragment that only contains the transformed XML data. An XSLT fragment is embedded in a standard Web page much like a server-side include; a feed from the Yahoo! Weather RSS service (http://weather.yahoo.com/rss/) embedded in the home page of a ski resort is a good example of how an XSLT fragment would be used. XSLT fragments are used far more frequently on the Web in general, whereas XSLT pages are more often seen in intranet applications.

Including XSLT fragments The comparison of an XSLT fragment to a server-side include (SSI) is a good one, for a number of reasons: n Neither type of file can be viewed independently on the Web, because they both lack necessary HTML tags including , , and . n Both require an application server for display in a browser. Dreamweaver supports ASP, ASP.NET, ColdFusion, and PHP server models for XSLT fragments. n You can edit either an XSLT fragment or SSI in Dreamweaver with equal ease. n Each XSLT fragment and SSI appears to be a single entity when selected in the embedded page at design time. Unlike SSIs, XSLT fragments have a page type all their own and can be created directly from the New Document dialog box. To create an XSLT fragment, follow these steps: 1. Choose File ➪ New. 2. From the New Document dialog box’s General category, select the Basic page category and the XSLT (Fragment) entry; click Create when you’re ready. Dreamweaver then asks which data source you’d like to use for your new XSLT fragment, as shown in Figure 32-4.

FIGURE 32-4 Read the latest for any RSS feed by using the remote XML data option.

3. In the Locate XML Source dialog box, select the Attach A Local File On My Computer Or Local Area Network option if you want to incorporate data from a static XML file available on your system; use the Browse button to open the Select File dialog box or enter the path to the file by hand in the provided field.

992

Integrating with XML and XSLT

4. If you’re displaying XML data from a file on the Web, choose the Attach A Remote File On The Internet option and enter the full Internet address in the available field. 5. Click OK when you’re done. 6. Save the newly created document with an .xsl filename extension, that is, rssfeed.xsl.

Binding XSL data to the page Once the fragment page is created, you’re ready to create the HTML structure to hold the data and bind the data. You can use any standard HTML objects, like tables and

or
tags, to hold your data. The data itself is displayed in the Bindings panel, as shown in Figure 32-5. FIGURE 32-5 Once connected to an external XML source like an RSS feed, the Bindings panel displays the available data structure.

Optional element

Single element

Repeating element Attribute Dreamweaver provides the following visual indicators when displaying XML data: Child elements that occur once within a parent are identified with a double-angle-bracket. Child elements that occur one or more times are identified with a double-angle-bracket followed by a plus sign. Optional child elements are identified with a double-angle-bracket followed by a question mark. Attributes of a parent are identified with an at-sign, @.

993

32

Part VI

Enhancing Productivity and Web Site Management

Bind data to a page by dragging an element from the Bindings panel and dropping it in the desired place or by positioning your cursor on the page and double-clicking the selected data element in the Bindings panel. In addition to displaying XML data as text, you can also use it in a link. Select the text, data, or image you want to use as a link and then, from the Property inspector’s Link field, click the Browse for File icon. When the Select File dialog box opens, select Data Sources; the XML data tree appears just like in the Bindings panel. Choose the data field you want to use as the href value, typically labeled link or rss:link, and then click OK twice to close the open dialog boxes. The XML data appears in the Link field wrapped in braces, like this: {rss:link}.

TIP

The basic code inserted by Dreamweaver for XSL data looks like this:

where the value of the select attribute is the XPath description of where the data is located in the XML file. Forward slashes represent parent nodes, much like folders in a URL.

Repeating XSL data A common use of XSLT fragments is to incorporate results from an RSS feed onto the page. Generally, you would include a few heading elements, such as the main feed title and author, followed by a series of titles, short descriptions, and links, each concerning a particular item in the RSS feed. The layout for such a fragment often involves a table to contain the repeating data, as shown in Figure 32-6. FIGURE 32-6 Use basic HTML tools like headings and tables to structure the data in an XSLT fragment.

To display repeated data, an XSLT Repeat Region object is used. Similar to a Repeat Region server behavior, the XSLT Repeat Region object wraps the necessary code around a selection, typically one or more rows of a table. Just as you’d identify which recordset to use with a Repeat Region server behavior, the XSLT Repeat Region object requires that you identify which element in the XML schema repeats. You’ll remember that

994

Integrating with XML and XSLT

Dreamweaver identifies such items in the Bindings panel with a double angle bracket and plus sign combination. The XSL code for repeating elements is and, when applied to a table row, looks like this example:

...