Dreamweaver: Making Rollover Buttons and Using Template and Library Items

Dreamweaver is one of the premiere html editing programs available today. In addition to generating html, it also creates a limited amount of JavaScript, and even lets you create Flash buttons without leaving the program. Dreamweaver also has an exceptional file management system and ftp utility that works with it to manage both your local and remote web sites.

Let's explore the use of Dreamweaver's template and library capabilities. These are tools used to expedite the creation of Web pages and also for updating those pages more easily whenever changes are needed in the future.

In the process of learning about templates and library items we will also be creating a set of rollover buttons. Rollover buttons change when you roll your mouse pointer over them. Dreamweaver generates both html and JavaScript to accomplish these. A set of buttons used for getting around a web site is called a navigation bar.

 


Templates

A template is used to generate prefabricated files. The files that are generated can be modified to the extent that is permitted by limitations specified within the template at the time the template was created.

Dreamweaver templates are a lot like the templates you may have already used in programs such as Microsoft Word or Excel and the procedure for creating them is about the same. Typical uses of templates in Word are letterheads, memos, and envelopes.

In Dreamweaver, templates are used to rapidly turn out pages that are identical in most ways, but have differences in one or more specific areas. This can include pages used to display information such as individual items for sale or the biographies of each member of a company's management team. These types of pages would probably be expected to look almost the same except for a photo of the item for sale (or of the manager in the case of the latter) and the text related to it.

Top

The General Procedure

The process for creating a template is straightforward. First, you create a file with the formatting and layout that you want to use as the basis for future files. Then, you select from the File menu: Save as Template.

An important difference between Dreamweaver and your standard Word or Excel template is that with Dreamweaver you can designate certain areas as being changeable (editable) and others not editable (the default). This prevents you from inadvertently modifying those parts of the file that you may not want changed such as navigation buttons, background color, logo, email link, etc.

Whenever you want to create a new file and use a template file as your starting point, you use File -> New -> select the Templates tab ...then select the template you want to base your new page on.

A new file would open that would be identical to the template, however you would not be able to modify previously designated sections of it (the non-editable regions). Your changes would not effect the template file itself. To modify the template itself it is necessary to modify the template file.


Library Items

We will also create a library item from of a set of rollover buttons (a navigation bar) that we will create. Library items in Dreamweaver are parts of a page that you save and then reuse on the same or other pages.

The difference between a library item and a template is that a template provides an entire html page but a library item is just a part of a page. Library items can be things such as buttons, tables of images, or even sounds.

Dreamweaver saves templates as .dwt files and library items as .lbi files. As soon as you create one or the other, a folder is automatically created to contain them. You will find these folders in the top folder level of your site (your root folder).

Templates and library items are similar in that when you change the original template or library item file, every instance that has been derived from it can be updated with your approval. This makes it easy to make global modifications. Note however that the files that have been affected will need to be uploaded to your remote site.

Top

Prepare Your Folders and Get the Files

First of all, if you haven't downloaded Dreamweaver MX 2004, please do so: Macromedia Dreamweaver 30 day trial download

Create a folder named rooftop. Then create within it two other folders named: images and html. Within the images folder, create a sub-folder called navigation. Online students, get the following files from your Digital Drop Box* and place them in the folders specified:

  1. basic.html - put this in the folder: html.
  2. Put the following files in the folder: images:
  3. Put all of the files that start with nav_ in the navigation folder (which should be inside of the images folder). Note:

* Online students: when saving from the Digital Drop Box, follow these instructions:

  1. Do NOT use Internet Explorer's Save As option. It will save the files with the wrong file name. Instead, do the following.
  2. Right click on the link in the Digital Drop Box that leads to the file you want to save. (Mac users: control-click).
  3. Select Save Target As... This allows you to save the file to your hard drive using the original file name, which is important to the success of the exercise.

 

Top


Local Root Folder and the Cache

We will be defining a local root folder in a moment. First, an explanation about this. One of the most important things to do when using Dreamweaver is to create a folder on your computer and then designate it as the local site.

This is a step that allows Dreamweaver to handle file tracking and updating for you almost automatically. In order to accomplish this, Dreamweaver generates a cache of information about the files and folders in the site and the relationships between them (links, paths, etc.).

A local site is nothing more than a folder that you create that will be used to contain all of the files associated with the web site that you are creating. You can keep any files at all in it, not just your html, gif and jpeg files.

For example, you can store original image files, text files from your clients, production checklists, etc., in it. Ultimately you will also use it for uploading to the remote server the files that you want to be available on the Web.

Top


Define the Site

Launch Dreamweaver. First you will define the site.

  1. In the menu go to: Sites -> Manage Sites -> New -> Site
  2. The dialog box: Site Definition for Unnamed Site 1 will open.
  3. At the top of the dialog box, select the tab named Advanced
  4. On the left side, select the Category: Local Info
  5. Enter these items:
    1. Site Name: Rooftop Restaurant (note: the name of the dialog box now changes to Site Definition for Rooftop Restaurant)
    2. Local root folder:
      1. Click on the little folder icon to the right of the Local root folder selection window.
      2. This dialog box should open: Choose local root folder for site Rooftop Restaurant
      3. Navigate to the folder you created named rooftop
      4. Double click on it to select it:
        • The selection box near the top of the dialog box should now say Select. You ought to see the name of the folder rooftop in the Select box.
        • Also, in the lower left corner it should say Select:rooftop
        • In the lower right corner, the Select button ought to be available.
      5. Click on Select
    3. Default images folder:
      1. Next, click on the little folder icon next to the Default images folder selection box. Navigate to the images folder that you created inside of your rooftop folder.
      2. Select it in the same manner that you selected the rooftop folder before.
    4. HTTP address: leave this as is.
    5. Cache: Enable (check) the box Enable Cache
  6. Click OK to close the Site Definition dialog box.
  7. Then in the Manage Sites dialog box click on Done
  8. A message might pop up regarding cache. Agree to cache. This will enable Dreamweaver to have better control of file management.

Top


Designating a Preview Browser

Dreamweaver makes it easy to allow you to see your html file in your browser. Even though Dreamweaver does a fairly good job of displaying what your pages will look like in a browser, you can never be really certain what your file will look like until you open it in an actual browser.

This can be particularly true with web pages that use what are called Cascading Style Sheets as well as with the display of JavaScript functionality. Consequently, it is a good idea to make a habit of seeing what your page actually looks like in one or more browsers. That way you can be confident that your work displays the way you intended it to.

Let's make sure that you are set up in Dreamweaver for previewing your work in a browser easily. Note that this may already be properly set up in your Dreamweaver, therefore don't be surprised if these settings have already been established:

  1. In the Dreamweaver menu bar select File -> Preview in Browser -> Edit Browser List
  2. The Preferences dialog box will open set to the Category of: Preview in Browser
  3. Click on the Edit button.
  4. The Edit Browser dialog box opens.
  5. In the Application field, click on the Browse button to navigate to your Internet Explorer program, which you will probably find in a folder named something similar to Program Files on your C drive.
  6. Select the program, which will probably be named something innocuous such as IEXPLORE.EXE
  7. Then click Open (which is a misnomer, you are actually selecting it).
  8. For Defaults: enable Primary browser
  9. Click OK
  10. This will return you to the Edit Browser dialog box.
  11. Be sure to enable Options: Preview using temporary file. This allows Dreamweaver to preview your work in the browser without having saved the file or any changes that you have made to it.
  12. Click OK to accept the choices that you have made.
  13. Now press F12 on the top row of buttons on your keyboard.
  14. The basic.html file ought to open in Internet Explorer.

The Preview in Browser options allow you to preview your web pages in a wide variety of browsers. In order to do this you need to first have those browsers on your computer.

You can usually find downloads of older browser versions at the Microsoft and Netscape web sites, but you may need to dig deeply because these publishers are not in the habit of encouraging the use of their older browsers, although they usually provide them for web developers (like you!).

Now, using Dreamweaver's File menu, open the file basic.html. Press F12 on your keyboard. This file ought to now open in your browser.

Top

Making an Image Into a Link Using the Properties Panel

Click on the image of the banner at the top of the page. You will be able to tell if it's selected if:

Then look in the Properties panel which should be at the bottom of the Dreamweaver interface.

If you don't see it there, go to the Dreamweaver menu bar and select: Window -> Properties (or Ctrl-F3). The Properties panel is what you will probably find to be the most useful part of Dreamweaver.

The Properties panel changes depending on where the insertion point is or what is selected at that time. Make note that there is a little white triangle in the lower right corner of it. Click on it a couple of times. It allows you to expand or collapse additional options that may be available. I recommend that you leave the Properties panel open to the largest size.

With the image selected, the Properties panel will offer options related to it. You will notice an empty Link box. Fill this in with the URL of a site you like. You need to include the transfer protocol. For example, you might enter this: http://www.ucla.edu.

After you type in the URL press on the Enter key. Be forewarned that the page may all of a sudden shift to the left. That's OK. Use your scrollbars to return to viewing the left side of the page once again.

Directly underneath the Link box is a Target box. Targets are for controlling where the file specified by the link will open. Probably the most useful one is _blank.

It's an odd name, particularly with the preceding underscore. It causes the browser to open a new window and to have the linked page open in that new window. Select Target: _blank

Now click on F12 on your keyboard. This should open the page in your browser. If you move your pointer over the banner, the pointer will turn into a pointing hand icon, indicating the presence of a link.

Click on it. The link ought to open in a new window. When done, return to Dreamweaver.

Top


Library Items

Next, we will be creating rollover buttons and putting them in the small table in the vertical column on the left side of the web page. We will not create links for these rollovers now, however the rollover effect will work. Links can be added later.

Then we will save the table containing the rollover buttons in Dreamweaver's Library. We do this because if we were to create new pages for this site, many of them may be able to employ this new library item as a navigation bar. We would not need to recreate it each time it's needed. Instead, we can literally just drag a copy of it out of the library and put it on the page where we need it.

Furthermore, if we wanted to change anything about all of the uses of a particular library item, all we would need to do is to change the original library item's file. Then all derivative uses of it would change as well (our permission would be asked first).

For example, when the time came to apply links to the buttons we are about to make, we would only need to apply the links to the buttons in the library item. Then all instances where the library item is used could be automatically updated at the click of a button to include the new links or any other changes that are made.

Top


Rollover Buttons

What Dreamweaver refers to as a rollover image is actually two alternating images: the Up, or regular image and the Over image, which is the one that appears when you move your pointer on top of the rollover. As one might expect, they both need to be the same size. (The Up image is sometimes called the Original image.) Dreamweaver creates JavaScript code to make the rollovers work.

We will now fill the four cells with rollovers, inserting one rollover per cell, using the instructions that follow. The sequence of the rollover buttons will be, top to bottom:

  1. catch
  2. gourmet
  3. rave
  4. special

Top


Here's How To Do It

  1. If you haven't already click just to the right of the word "here" inside the of the top cell: the cell that has the text in it that says: put first rollover here.
  2. A flashing insertion bar should now be visible to the right of the words.
  3. Delete the text in that cell. All that you should see in the cell is the insertion point.
  4. In the Insert panel (which is probably just above your html file), in the Common section, find the fifth button from the left: it has a tree icon on it. This is the Images: Rollover Image button.
  5. Click and hold down your mouse button on the little down pointing triangle to the right of it. This will provide several options to choose from.
  6. From the drop down menu that appears, select: Rollover Image.
  7. In the resulting dialog box (the Insert Rollover Image dialog) leave the Image name as is. This is used by JavaScript but you don't need to be concerned with it for this exercise.
  8. For the Original image, click on the Browse button. Search for the images/navigation folder.
  9. From there, select the file: nav_catch_UP.gif
  10. For the Rollover image select nav_catch_OVER.gif
  11. Enable Preload rollover image. This means that the browser will be instructed to request and download into its cache the image that will be used for the rollover. That way, there will be no delay waiting for the image to download when the viewer moves their mouse over the rollover.
  12. Click OK without filling in the other boxes.
  13. The rollover effect will not be visible in Dreamweaver.
  14. Click on F12 to test the rollover effect in the browser.
  15. Congratulations, you have just made your first rollover button (and generated JavaScript code to go with it)!
  16. Follow this same procedure in the 3 remaining cells removing the text from each cell as you proceed.

Top


Making the Library Item

Next we will select the part of the page that we want to convert into a library item: the navigation bar. We intend to use it on multiple pages.

How do we select the navigation bar? It actually has two containers: a table (with the four cells) which is inside of what Dreamweaver calls a layer.

Layers use code that define a specific location on a page, tables do not. Therefore, we want to select the table in the event that we may want the navigation bar in slightly different positions on different pages.

  1. To select the table that has the rollover buttons in it, first click inside any of the table's cells.
  2. Then select the table tag in the Tag Selector area at the bottom of your file's window. The Tag Selector is a row of html tags (see illustration above) that is handy for easily selecting objects on the page that might otherwise be difficult to select.
  3. From the main menu bar select: Modify -> Library -> Add Object to Library
  4. This should open up the Assets panel.
  5. In the Assets panel, the Library option ought to be selected. It is the icon that looks like a little open book at the bottom of the column of icons on the left edge of the Assets panel.
  6. The navigation bar ought to be visible in the Library. The name of it (Untitled) should be highlighted, waiting for you to type in a new name for it. Type in and name it navBar.
  7.  

Dreamweaver will automatically create a new folder in the site root folder called Library and will put this library item in it using the extension: .lbi (library item).

Top


Converting Layers to Tables

Now we will convert the file so that it is made up entirely of tables. That's because some of the much older browsers (those older than version 4) can't see what Dreamweaver's layers. They had been used to position and compose most of the parts of the page.

The file currently has three layers. The layers have been useful assembling the parts of the page because they simplified the positioning of items thus expediting the creation of a nice composition.

Converting layers to tables is very easy with Dreamweaver. You can also convert tables back to layers if you want to use them again later to make readjustments to the page composition.

There is one thing that may cause a problem, and that is if any of your layers are overlapping, even a tiny bit, then Dreamweaver will not permit the transition. Dreamweaver will tell you which layers are overlapping.

If you get that message, you will need to slightly move the offending layer(s) so that they don't overlap:

  1. First, from the main menu bar select: Modify -> Arrange -> Prevent Layer Overlaps.
  2. You will have to move your layers a bit until you no longer get that error message. To do this, you can easily select the layers using the Layers panel. To open the Layers panel, from the main menu bar select: Window -> Layers.
  3. Once a layer is selected, you can then use the arrow keys on your keyboard to reposition the layer until it's not overlapping other layers anymore.
  4. Once you have corrected any layers from overlapping, and the Prevent Layer Overlaps checkbox is enabled, you can no longer overlap layers in the future, which is good in this case.

Top


To Convert Layers Into a Table

  1. From the main menu bar select: Modify -> Convert -> Layers to Table
  2. A dialog box called Convert Layers to Table will open.
  3. Accept the default settings by clicking OK.

You've done it! The layers will no longer be there: a table has replaced them and the page ought to look identical to the way it looked before, or close to it. Press F12 on your keyboard to preview the page. All the rollovers should continue to work.

Top

Create a Template

Next, we will make our page into a template so that we can easily create new pages based on it without having to assemble them from scratch. Our page is intended to be for displaying dinner specials. There may be many of these special dishes that you would want to have web pages available for. Using a template will make this much easier.

  1. From the main menu bar select: File -> Save as Template
  2. The Save as Template dialog box will open.
  3. In the text box labeled Save as name it special.
  4. The Assets panel ought to open once again, however this time to the Templates category. This is represented by an icon of a page of paper and is one icon above the Library icon.

Dreamweaver will save the template as a file and add the file extension .dwt (DreamWeaver Template) to it. Dreamweaver will also automatically create a new folder called Templates in your site's root folder and put this new template file in it.

Top


Designate an Editable Region

Unless you specify areas of a Dreamweaver template to be editable, you will not be allowed to modify the files made from a template at all, with the exception of changing the page title. Therefore, you need to specify which parts of the page you want to be able to change.

In our template there are two areas that we would want to be able to modify in any of the files derived from this template. Each of these are table cells. The two cells are in the middle of the page, colored orange and green, and they have labels typed inside of them. To make them each editable, follow these steps for each of the two cells:

  1. Click inside the upper (orange) cell.
  2. Select the furthest right <td> (cell) tag in the Tag Selector (the area at the bottom of the image window). Be sure to open the window wide enough to see all of the tags - make sure you select the <td> tag furthest to the right.
  3. From the main menu bar select: Insert -> Template Objects -> Editable Region
  4. In the New Editable Region dialog box that opens, supply the name for the editable region: photo
  5. Save the template file (File -> Save).
  6. Repeat the steps for the food description cell: click in it first, then follow steps 2 through 5, however name its editable region description
  7. Save your template file (File -> Save).

Top


Making a File From a Template

Let's make a new file from the template just to make sure it works:

  1. From the main menu bar select: File -> New
  2. The New Document dialog box opens.
  3. At the top left of it click on the Templates tab.
  4. special should be listed.
  5. Select it.
  6. Click on Create
  7. When the new file opens you will see the NO symbol (a circle with a diagonal line through it) appear instead of an arrow everywhere your mouse pointer goes except over the two cells you had made editable.
  8. Click inside the cell for the photo. If you wanted to you could now insert an image of food here. However there is no need for you to do this, so please don't bother.
  9. Then click in the lower cell and type in your own description of a favorite dish of yours.
  10. Press on F12 to preview the page in the browser. Check that the rollovers work.
  11. Save the new file as: ROL_yourlastname.html
  12. Send me the file via drop box.

Congratulations. That's it. I hope you enjoyed making rollovers, a library item and a template. This is what a final page from the template might look like:

Top


Copyright © 2004 Dan Vaughan and its licensors. All rights reserved.