Compare Snippets to Library Items Compared to snippets, Library items are much smarter. They possess the unique ability to update the same material on an entire site’s worth of files in seconds, and can successfully deal with links and images. Snippets are available for all sites you build. Unlike snippets, however, Dreamweaver’s Library feature is site-specific: Each site you set up in Dreamweaver has its own Library, and Dreamweaver stores that Library’s files along with all the site’s other files. You can’t use a Library item from one site when you’re working on a page from another site.
Snippets Basics Snippets aren’t fancy or complex, but they sure save time. A snippet is simply a chunk of code you store away and then plunk into your web pages as necessary. You keep these code chunks in the Snippets panel and summon them in a couple of ways: – Choose Window → Snippets. – Windows people can press Shift-F9. There’s no Mac keyboard shortcut for the Snippets panel, but you can create your own, using Keyboard Shortcuts
Using Snippets Snippets come in two varieties: – those that are simple blocks of code, – those that wrap around a currently selected element in a document. To add a snippet to a web page, click in the document where you want the item to go, or select the object you wish to wrap with a snippet. Do one of the following: – On the Snippets panel, double-click the name of the snippet. – On the Snippets panel, select the snippet, and then click the panel’s Insert button. – Drag the snippet from the panel into the document window. (If the snippet is supposed to wrap a selection, drag the snippet onto the selected object.)
Add a Snippet to a Web Page Click in the document where you want the item to go, or select the object you wish to wrap with a snippet. Then do one of the following: – On the Snippets panel, double-click the name of the snippet. – On the Snippets panel, select the snippet, and then click the panel’s Insert button. – Drag the snippet from the panel into the document window. If the snippet is supposed to wrap a selection, drag the snippet onto the selected object
Snippet info Snippets simply dump their contents into a document — essentially copying the snippet code and pasting it into your web page; Dreamweaver doesn’t step in to make sure that you’re adding the code correctly.
Library Basics Imagine : You manage a large website consisting of thousands of pages. At the bottom of each one sits a simple copyright notice. Each time you add another page to your site, you could retype the copyright and apply format to it. The Library feature can turn anything you select in the document window (a paragraph, an image, a table) into a reusable chunk of HTML that you can easily drop into any Dreamweaver document. Keep in mind that Library items can contain only page elements that appear in the document window — in other words, only HTML from the section of a web page.
Library Basics You can’t include anything that appears in the of a page, like Cascading Style Sheets, Spry widgets,or meta tags. This means you can’t store Dreamweaver behaviors or Spry widgets in your Library, Library items must include a complete set of HTML tags — both an opening and a closing tag — as well as all the tags necessary to complete the original object. – For example, Dreamweaver doesn’t let you turn just a single cell, row, or column of a table into a Library item. If you try, Dreamweaver will add the entire table to the Library.
Creating and Using Library Items To create a Library item, start by opening the Library window. Click the Assets tab (to the right of the Files tab) or choose Window → Assets, and then click the Library items button
Add an Item to theLibrary Add the selection to the Library. Dreamweaver provides several ways to do this: – Drag the highlighted selection into the list of Library items. – Click the New Item button ( Figure 18-4 ). – Choose Modify → Library → Add Object to Library. The new item appears in the Assets panel, bearing the jaunty name “Untitled.” Type in a more useful name.
Add a Library Item to WebPage Add a Library item to a web page, drag it out of the Assets panel’s Library items list onto your page. The long way: – Click to plant your insertion point on the page, – click the Library item you want in the Assets panel, – in the Assets panel, click the Insert button. Assignment – Snippets & Library Tutorial – Book page 842 Kindle 18001