Those of you who follow the Fireworks forum postings will probably recognize my name. I suppose I may have gotten a reputation as a crusader who opposes the use of the original Fireworks Pop-Up Menu as implemented in Macromedia Fireworks MX 2004 and earlier. I'm here to tell you that you are absolutely right. There are more than a few reasons not to use those pop-up menus, in my opinion, and I have spent a fair amount of time posting to this effect.
So why am I writing this article, then? Well, I have an agenda, as follows:
To cut to the chase, I am happy to tell you that this feature is greatly improved in Fireworks 8.
In this article I briefly describe the creation of a menu in various modes. I examine and discuss the markup created by Fireworks ready for import into Dreamweaver, and describe what I think might be useful improvements to consider in the resulting markup.
To complete this tutorial you will need to install the following software:
Some degree of fluency with HTML and CSS, as well as prior experience with pop-up menus in Fireworks.
Those of you who have used the pop-up menu feature in earlier versions of Fireworks will be right at home in the current one. The setup and dialog panel are identical in Fireworks MX 2004 and Fireworks 8, offering exactly the same options and choices. Using this feature in Fireworks 8, you can build visually pleasing menu sets. It's easy to see its appeal.
To examine the pop-up menus that Fireworks 8 creates, you will need to create several extremely simple files. For the first one, open Fireworks and select File > New to create a new page—say, 640 x 400 pixels. Select the text tool and enter Link1 anywhere on the page.
Exit the text tool and then draw a slice around Link1 (I made mine 41 pixels wide and 23 pixels tall). Select it, name it link1button, use the selected slice's bull's-eye to drop the context menu, and select Add Pop-up Menu from the menu choices. A panel will open, and you will make this slice show a simple, single-option submenu. In this panel enter Sub1-1 under the Text column head. There is no need to enter a link or a target.
Now click the Next button to advance to the Appearance tab (or just click the tab), where you can select that this is a vertical menu. With no further adjustment, the submenu will be drawn on top of the top menu choice, so you should advance to the Position tab and click the second position icon from the left. Leave the rest of the settings in this and the other tabs at their default values, and conclude this menu by clicking Done. Save this file as singlebutton.png.
Preview the menu by selecting File > Preview in Browser and then choosing your browser of choice. You should see a single-button menu which, upon rollover, drops a single-option submenu.
With singlebutton.png still open, you can now add more buttons to the menu. For the purposes of this tutorial, you will add three more menu buttons and give each of them a single pop-up submenu. To do this, deselect the visible slices option in the Web Layer tools, double-click Link1, and append Link2 Link3 Link4 to it (I have put two spaces between each link name).
Now exit text mode, enable the visible slices option, and select the slice tool to add a slice of similar dimension to link1button to each of the three new menu options. Beginning with Link2, name each new slice using a nomenclature similar to that used previously: link2button, link3button, and link4button. One by one, select each new slice and use the bull's-eye to add a pop-up menu with a single submenu: Sub2-1, Sub3-1, and Sub4-1. Save this new menu arrangement as fourbutton.png.
A preview in browser should once again reveal what good work you do.
Now that you have two menus created—one with a single button and a single pop-up menu, and one with four buttons, each with a single pop-up menu—it's time to get these into Dreamweaver and examine the markup.
Open singlebutton.png and select File > Export. Choose a landing site for the files from this (I created a folder called single and placed these files into that folder). Looking closely at the Export panel, make sure that the Export field is set to HTML and Images, the HTML field is set to Export HTML File, and the Slices field is set to Export Slices, with the Include Areas Without Slices check box also enabled.
Click the Options button and choose your favorite HTML style and extension. Of the four check boxes on that HTML Setup panel, you need to have at least the bottom two selected (Use CSS for Popup Menus and Write CSS to an External File). Click OK to get out of this HTML Setup panel and the previous Export panel to save the files.
Do the same for fourbutton.png (I created a folder called fourbutton and placed these files there). You have now created all the files you need for the remainder of this tutorial. For me, this process gets the following relevant files in the single folder (and analogous ones in the fourbutton folder): singlebutton.html, singlebutton.css, and mm_css_menu.js. The singlebutton files will be used to describe the details of the menu and its construction. The fourbutton files are there to examine the CSS needed for this slightly more "real-world" example.
The process of inserting these menus into Dreamweaver is exactly the same as it has been for several releases now. Open your Dreamweaver page, place the insertion point where you want the menu inserted, and select Insert > Image Objects > Fireworks HTML. For the remainder of this tutorial, you will examine the code written by Fireworks to understand how these menus are built and how they work. I will use the original files written by Fireworks 8 for this explanation.
A glance at the HTML immediately reveals that these menus are very different from those built in earlier versions of Fireworks. The most significant difference is that the links are not written into plain HTML markup on the page.
In Dreamweaver, I have defined a site especially for this tutorial. The root of this site contains both the single and the fourbutton folders. To see how Fireworks creates these menus, you should start simple. Use the Code view in Dreamweaver to take a look at the contents of singlebutton.html in the simple folder. You should see the following (the markup follows):
The salient HTML markup is shown here (along with my additions and showing the naming convention adopted for the divs):
<div id="FWTableContainer165705776"><!-- This is the outer menu container div -->
<table border="0" cellpadding="0" cellspacing="0" width="640"><!-- This is the menu table -->
<!-- fwtable fwsrc="singlebutton.png" fwbase="singlebutton.gif" fwstyle="Dreamweaver" fwdocid = "165705776" fwnested="0" -->
<tr>
<!-- Shim row, height 1. -->
...snip...
<tr><!-- row 1 -->
...snip...
</tr>
<tr><!-- row 2 -->
<td rowspan="2">...snip...</td>
<td><a href="javascript:;" onMouseOut="MM_menuStartTimeout(1000);" onMouseOver="MM_menuShowMenu('MMMenuContainer0817151145_0', 'MMMenu0817151145_0',0,23,'link1button');"><img name="link1button" src="images/link1button.gif" width="41" height="23" border="0" alt=""></a></td><!-- This is the top menu link image (link1button) -->
<td rowspan="2">...snip...</td>
<td>...snip...</td>
</tr>
<tr><!-- row 3 -->
<td>...snip...</td>
<td>...snip...</td>
</tr>
<!-- This table was automatically created with Macromedia Fireworks -->
<!-- http://www.macromedia.com -->
</table>
<div id="MMMenuContainer0817151145_0"><!-- This is the submenu div -->
<div id="MMMenu0817151145_0" onMouseOut="MM_menuStartTimeout(1000);" onMouseOver="MM_menuResetTimeout();">
<a href="#" id="MMMenu0817151145_0_Item_0" class="MMMIFVStyleMMMenu0817151145_0" onMouseOver="MM_menuOverMenuItem('MMMenu0817151145_0');">
Sub1-1
</a>
</div>
</div>
</div>
The menu function is controlled by event handlers applied to the various </div> tags. The logic is remarkably similar to the logic we used some years ago when such menus were created with DHTML timelines! Moving the mouse over the top menu link shows the submenu with a call to MM_menuShowMenu, while moving the mouse away starts an internal timer. When this timer fires, the submenu is closed. Moving the mouse over the submenu div stops the timer started above, with a call to MM_menuResetTimeout, while moving the mouse away from this div starts it again.
The CSS for this menu is written as follows:
position:relative for the menu div. This allows the menus to exist inside a table cell if necessary, even though they use absolute positioning.The details of the CSS file's rules can be obtained by examining the respective CSS files produced by the export.
For singlebutton.html, the CSS file is 81 lines long. For fourbutton.html, the CSS file is 282 lines long; the additional lines are required for the individual styling allowed for each submenu. This means that more complex menus require longer and longer CSS files.
I would be remiss if I didn't say more about this particular naming scheme. The nomenclature for the div tag IDs (hence their style rule selectors) is quite obscure, not to mention voluminous. Perhaps it would be possible to look to the slice names as a way of simplifying these IDs, thereby reducing the space requirements for them to be listed—not only on the tag selector in Dreamweaver but also in the code and CSS. As a user, you might want to edit these manually to something a bit more readable.
In addition, providing an option to style each submenu independently of the others (this is really imposed by the user interface for the menus because each submenu is a separate entity) appears to offer great flexibility, but it comes at a heavy price. The markup on the page as well as the selector nomenclature is unnecessarily complicated by this flexibility. My personal opinion is that this extra styling for each submenu is unnecessary. The menu system would profit greatly from this simplification.
In summary, I think the design of these pop-up menus is relatively standard, if not leading-edge. Most menu systems now being shown, discussed, and used are built on a nested list model rather than isolated anchor tags with show-hide div actions. The real benefit of the former approach is simplicity in presentation when JavaScript is not available and in semantic markup—lists having an inherent meaning, not shared by a series of adjacent anchor tags. I would personally like to see such an approach as a future enhancement in Fireworks.
The menu should work well with Dreamweaver templates and should also be easily modified or debugged by someone with modest HTML/CSS skills. The menus themselves are readable by search engine spiders, although—like many other menu systems—they will not function without JavaScript enabled.
A final word of encouragement is appropriate, I think. I am heartened to see that it is possible to open an "old-style" menu and resave it as a CSS menu. This is a needed lifeline, in my opinion, for those who may be struggling with the previous all-JavaScript menus. I welcome its inclusion.
Murray R. Summers is an Adobe Certified Web Site Developer, Dreamweaver Developer, and Community Expert. He has contributed chapters to several books on Dreamweaver and co-authored a book on Dreamweaver Templates. He used to be a technical editor of Roadmap to Macromedia Contribute by Joseph Lowery (Macromedia Press, 2003) and a number of issues of The Missing Manual series for Dreamweaver, including the one for Dreamweaver CS4. He has served as an invited speaker at every TODCON (international) conference since 2001 (missing only 2008). His company, Great Web Sights, has been active in web development since 1998. Murray lives in the rural Philadelphia area with Suzanne, his wife, and Carly, his daughter, who is currently attending Clemson University (go Tigers!).