Making and Applying a Library Object

Library Object

A Library Object is code added to a web page by you that brings in other code (text, image, etc.) from another file, but it is done by Dreamweaver while you're working on the page on your computer. When you upload the page to the server, the code from the library is already embedded in the page.

Advantage and Disadvantage

Advantage

A Library Object allows you to easily manage site wide or often repeated elements in your web design. In other words, repetitious stuff! By changing the code in one file, many files can be automatically updated with the new code.

Disadvantage

Make a Library Object

To see how this is done, create a file named "LibraryObject.html":

  1. go to the "File" menu
  2. choose "New..."
  3. in the dialog box click on the "General" tab
  4. in the "Category:" column choose "Basic Page"
  5. in the "Basic page:" column choose "HTML"
  6. click "Create"
  7. title the page "Library Object"
  8. save as "LibraryObject.html"

In the main editing window, do the following:

  1. type in the following text
    • This is a relative link to my other page
    • This is an absolute link to my favorite Web site
  2. insert an image grabbed from the Web (remember to put this image in your "DWManagement" folder)
  3. save your changes

Now, make a Library Object out of the text and image:

  1. select the text and image
  2. go to the "Modify" menu
  3. choose "Library>Add Object to Library"
  4. name it "Repetitive Stuff for Every Page"
  5. hit "return" (Mac OS) or "enter" (Windows)

Apply a Library Object

To see how this is done, do the following:

  1. delete everything from the current page
  2. add the following text:
  3. hit "return" (Mac OS) or "enter" (Windows)

Now insert the Library Object:

  1. go to the "Window" menu
  2. Figure 2: Assets Panel

    Figure 2: Assets Panel

    choose "Assets" to open the Assets Panel (see Figure 2: Assets Panel)
  3. click on the "book" icon in the left column (it's at the bottom of the icons)
  4. click on the Library Object "Repetitive Stuff for Every Page" in the Library panel (not pictured)
  5. click on the "Insert" button at the bottom left of the panel

Edit a Library Object

  1. go to the "Window" menu
  2. choose "Assets" to open the Assets Panel (see Figure 2: Assets Panel)
  3. click on the "book" icon in the left column (it's at the bottom of the icons)
  4. double-click the desired Library Object (e.g., Repetitive Stuff for Every Page)
  5. edit away!
  6. save the changes

Dreamweaver will ask if you want to update your pages.

  1. choose "Update"
  2. read the report Dreamweaver generates
  3. when you're done with the report click "Close"

Remember any page affected by the change to the Library Object will need to be uploaded to the Web server for the world to see the changes.

When you're ready, move on to "Creating and Applying a Template."