In the Document window, switch to Design view and select a portion of a document to save as a library item.
Use this topic to learn how to create library items in Dreamweaver, and insert and edit library items in documents.
A library is a special Dreamweaver file containing a collection of individual assets or copies of assets that you can place in your web pages. The assets in a library are called library items. Items that you can store in a library include images, tables, sounds, and files created with Adobe Flash. You can automatically update all the pages that use a library item whenever you edit the item.
For example, suppose you’re building a large site for a company that wants a slogan to appear on every page. You can create a library item to contain the slogan and use that library item on every page. If the slogan changes, you can change the library item and automatically update every page that uses it.
Dreamweaver stores library items in a Library folder within the local root folder for each site. Each site has its own library.
You can create a library item from any element in the body section of a document, including text, tables, forms, Java applets, plug‑ins, ActiveX elements, navigation bars, and images.
For linked items such as images, the library stores only a reference to the item. The original file must remain at the specified location for the library item to work correctly.
It can still be useful to store an image in a library item, though. For example, you could store a complete img tag in a library item, which would allow you to easily change the image’s alt text, or even its src attribute, throughout the site. (Don’t use this technique to change an image’s width and height attributes, though, unless you also use an image editor to change the actual size of the image.)
If the library item contains links, the links may not work in the new site. Also, images in a library item aren’t copied to the new site.
When you use a library item, Dreamweaver inserts a link to it, rather than the item itself, in the web page. That is, Dreamweaver inserts a copy of the HTML source code for that item into the document and adds an HTML comment containing a reference to the original, external item. It is this external reference that makes automatic updating possible.
When you create a library item that includes an element with a Dreamweaver behavior attached to it, Dreamweaver copies the element and its event handler (the attribute that specifies which event triggers the action, such as onClick, onLoad, or onMouseOver, and which action to call when the event occurs) to the library item file. Dreamweaver does not copy the associated JavaScript functions into the library item. Instead, when you insert the library item into a document, Dreamweaver automatically inserts the appropriate JavaScript functions into the head section of that document (if they aren’t already there).
If you hand-code JavaScript (that is, if you create it without using Dreamweaver behaviors), you can make it part of a library item if you use the Call JavaScript behavior to execute the code. If you don’t use a Dreamweaver behavior to execute the code, the code isn’t retained as part of the library item.
There are special requirements for editing the behaviors in library items. Library items cannot contain style sheets, because the code for those elements is part of the head section.
In the Document window, switch to Design view and select a portion of a document to save as a library item.
Select Tools > Library > Add Object to Library.
Dreamweaver saves each library item as a separate file (with the file extension .lbi) in the Library folder of the site’s local root folder.
If something is selected, it will be placed in the new library item.
In the Assets panel, select the Library category.
Click the New Library Item button at the bottom of the panel.
When you add a library item to a page, the actual content is inserted in the document along with a reference to the library item.
In the Assets panel, select the Library category.
To insert the contents of a library item without including a reference to the item in the document, press Control (Windows) or Option (Macintosh) while dragging an item out of the Assets panel. If you insert an item this way, you can edit the item in the document, but the document won’t be updated when you update pages that use that library item.
Select a library item, and click Insert.
When you edit a library item, you can update all documents that use that item. If you choose not to update, the documents remain associated with the library item; you can update them later.
You can rename items to break their connection with documents or templates, delete items from the site’s library, and recreate a missing library item.
In the Assets panel, select the Library category.
Either Click the Edit button or double-click the library item.
Dreamweaver opens a new window, similar to the Document window, for editing the library item. The gray background indicates that you’re editing a library item instead of a document.
Specify whether to update the documents on the local site that use the library item. Select Update to update immediately. If you select Don’t Update, documents won’t be updated until you choose Tools > Library > Update Current Page or Update Pages.
Select Tools > Library > Update Current Page.
Select Tools > Library > Update Pages.
To update all pages in the selected site to use the current version of all library items, select Entire Site, then select the site name from the adjacent pop‑up menu.
To update all pages in the current site that use the library item, select Files That Use, then select a library item name from the adjacent pop‑up menu.
To update templates at the same time, select Templates as well.
Dreamweaver updates the files as indicated. If you selected the Show Log option, Dreamweaver generates a report showing whether files were updated successfully, along with other information.
In the Assets panel, select the Library category.
When you delete a library item, Dreamweaver removes it from the library but doesn’t change the contents of any documents that use the item.
In the Assets panel, select the Library category.
If you delete a library item, you can’t use Undo to retrieve it. You may be able to recreate it, however.
You can customize the highlight color of library items and show or hide highlighting by setting Highlighting preferences.
To show highlighting, select View > Design View Options > Visual Aids > Invisible Elements. To hide highlighting, deselect Invisible Elements.
You can use the Property inspector to open a library item for editing, detach a selected library item from its source file, or overwrite an item with the currently selected library item.
Src
Displays the filename and location of the source file for the library item. You can’t edit this information.
Open
Opens the library item’s source file for editing. This is equivalent to selecting the item in the Assets panel and clicking the Edit button.
Detach From Original
Breaks the link between the selected library item and its source file. You can edit the detached item in the document, but it’s no longer a library item and isn’t updated when you change the original.
Recreate
Overwrites the original library item with the current selection. Use this option to re-create library items if the original library item is missing or has been accidentally deleted.
If you’ve added a library item to your document and you want to edit the item specifically for that page, you must break the link between the item in the document and the library. Once you’ve made an instance of a library item editable, that instance isn’t updated when the library item changes.
To edit a behavior in a library item, you must first insert the item in a document, then make the item editable in that document. After you’ve made the changes, you can re-create the library item, replacing the item in the library with the edited item from your document.
Note the name of the library item, as well as the exact tags it contains. You’ll need this information later.
In the Assets panel, select the Library category.
Be careful to select exactly the same elements that were in the original library item.
In the Assets panel, click the New Library Item button, then give the new item the same name as the item you deleted, using the same spelling and capitalization.
To update the library item in your site’s other documents, select Tools > Library > Update Pages.
Sign in to your account