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
- A Library Object embeds in the page before the page is uploaded to the server. You have to upload every page that is affected by the Library Object or some of your pages on the web server will have incorrect information.
Make a Library Object
To see how this is done, create a file named "LibraryObject.html":
- go to the "File" menu
- choose "New..."
- in the dialog box click on the "General" tab
- in the "Category:" column choose "Basic Page"
- in the "Basic page:" column choose "HTML"
- click "Create"
- title the page "Library Object"
- save as "LibraryObject.html"
In the main editing window, do the following:
- type in the following text
- This is a relative link to my other page
- This is an absolute link to my favorite Web site
- insert an image grabbed from the Web (remember to put this image in your "DWManagement" folder)
- save your changes
Now, make a Library Object out of the text and image:
- select the text and image
- go to the "Modify" menu
- choose "Library>Add Object to Library"
- name it "Repetitive Stuff for Every Page"
- hit "return" (Mac OS) or "enter" (Windows)
Apply a Library Object
To see how this is done, do the following:
- delete everything from the current page
- add the following text:
- Here is some text that is unique to this page, so it does not make a good Library Object candidate.
- hit "return" (Mac OS) or "enter" (Windows)
Now insert the Library Object:
- go to the "Window" menu
- choose "Assets" to open the Assets Panel (see Figure 2: Assets Panel)
Figure 2: Assets Panel
- click on the "book" icon in the left column (it's at the bottom of the icons)
- click on the Library Object "Repetitive Stuff for Every Page" in the Library panel (not pictured)
- click on the "Insert" button at the bottom left of the panel
Edit a Library Object
- go to the "Window" menu
- choose "Assets" to open the Assets Panel (see Figure 2: Assets Panel)
- click on the "book" icon in the left column (it's at the bottom of the icons)
- double-click the desired Library Object (e.g., Repetitive Stuff for Every Page)
- edit away!
- save the changes
Dreamweaver will ask if you want to update your pages.
- choose "Update"
- read the report Dreamweaver generates
- 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."