Dreamweaver Basics

Tip #22

Creating and using library items

Dreamweaver 4.0 introduced a feature that allows you to place objects into libraries and this feature was continued in the MX and 2004 versions. These objects can be referenced in other documents throughout your site. The advantage of using libraries is that editing the object in one place allows you to update the object any place it has been used. Objects in libraries can be almost anything: a paragraph of text, an image, a link, a table, a form, a Java applet, and so forth.

To create a library item:

  1. Be sure that the site/files panel is displaying and then click on the Assets tab.
  2. Click on the Book icon at the bottom which is the symbol for the Library assets.
  3. Select a portion of a document (like the text that will be in the library or a graphic that will be in the library) to save as a library item.
  4. Drag the selection into the Library panel.
  5. Enter a name for the new library item. Each library item is saved as a separate file (with the file extension .lbi) in the Library folder of the site's local root folder.

Below is an example of a screen capture, showing three items inthe library. One is a link, one is contact information that will be repeated throughout a site, and one is the oval logo to be used on several pages.

Your assets list includes items which are in Libraries

To insert a library item in a document:

  1. Place the insertion point in the Document area where the item will be placed.
  2. Be sure that the Assets panel is diplaying and you have selected the Library (book) icon to see the list of library items for the site.
  3. Drag a library item from the Assets panel to the Document window, or select an item and click the Insert button at the bottom of the panel.

When you change items in the library, like adding text perhaps to the "contact" item in your library, and you save the item, you are prompted if you want to update the files which reference the library item. I cannot think of when you would not select the option to update the files. Prompt for updating library items in all files using library items.

The feature of libraries is just one way to speed up coding and provide consistency on pages in your site. Another feature is cascading or regular style sheets (already described in another tip) and the use of templates (which will be covered in another tip).

Library items should be things used on multiple pages on your site, not items used on a single page.

These tips are created as part of a class on Dreamweaver Basics.