close ad
 
Important WebAssist Announcement
open ad
View Menu

Web development tutorial

Create dynamic menu navigation

Tutorial created by Ray Borduin, WebAssist

Categories: Design Extender, Dreamweaver, PHP

rating

CSS Menu Writer - a former stand-alone extension that is now included in Design Extender - allows you to easily build navigation for your website.

This tutorial presents the steps for creating database-driven drop-down navigation, meaning we will build navigation with multiple tiers where the names and links of the menu items are based on information in your database. In this tutorial, we display categorized products in a drop-down menu, but this concept can be applied to any nested menu items.

arrow downWhat do you need to start?

  1. Dreamweaver CS3 or higher.
  2. Design Extender (alternatively, CSS Menu Writer) installed and activated in Dreamweaver.
  3. Site defined in Dreamweaver. For assistance, view these tutorials: Define a dynamic site in CS4 or Define a dynamic site in CS5+.
  4. PHP web page and connection in Dreamweaver to your database. For assistance, view this tutorial: Create a PHP database connection.
  5. MySQL database that includes one table for product categories and another table for products. If you do not have a database, you can download our free eCommerce MySQL database in this tutorial.
To easily apply your navigation to all the pages in your site, it is advised that you insert your menu within a Dreamweaver template that is applied to all the pages in your site. This way, menu updates that you save will be quickly applied to all pages.

arrow downUnderstanding the database architecture

The database used in this example contains two tables, products and productcategories. These two tables are connected by the ProductCategoryID column, the unique key column for the productcategories table. In the products table, make sure that each product has a numeric value in the ProductCategoryID column that matches one of the values in the CategoryID column of the productcategories table.

In the products table, ProductCategoryIDs match...


...a CategoryID in the productcategories table.

arrow downCreate the product category menu

The first step in creating a dynamic menu uses the productcategories table from the eCommerce MySQL database. Alternately, you can use any database table with at least two columns.

  1. Go to Webassist > CSS Menu Writer to open the wizard.

  2. In the Contents, choose one of the menu presets.

  3. Choose your desired Type, Category, and Theme.

  4. Next to Contents, click the Define button.


  5. Within the menu tree structure, use the Add and Delete icons to modify the menu items.

  6. Select the menu item (i.e. Products) that will contain the dynamic menu items (i.e. product categories).

  7. Click the Add icon.


  8. Select Add new dynamic link.
    You must be using a a PHP page to be presented the interface for choosing a dynamic link.


  9. Click OK.

  10. In the Dynamic Menu Item interface, choose your database connection.

  11. Choose the productcategories database table.

  12. From the Label menu, choose CategoryName.

  13. From the Key column menu, choose CategoryID.

  14. In the Link field, enter the link you wish to use for each menu item. If the link is to be dynamic, choose the Add to link icon to specify a parameter to be set. Use # if no link is desired. If you have used DataAssist to create product results pages, you would likely want to link to them. In this situation, follow these steps.

    How to create a link to a DataAssist results page:

    1. Select the browse icon and choose your results.php page. This name may vary based on your DataAssist options.
    2. Append ?CategoryID= where CategoryID is the key column you selected above.
    3. Click the Add to link icon and choose the CategoryID option.
    4. For example, results.php?CategoryID=[CategoryID]

  15. Filtering and sorting is optional.


  16. Click Finish.
When you return to the CSS Menu Writer interface in Dreamweaver, the dynamic option displays as a single item regardless of the database contents. You will also notice that in any preview windows, your dynamic options are not displayed.

arrow downCreate the product menu

  1. Select the dynamic option we just set up.

  2. Choose the Add icon.


  3. Select Add new dynamic link.


  4. Click OK.

  5. Choose the same database connection.

  6. Choose the products database table for your menu items.

  7. From the Label menu, choose the column from the database table that contains the names to be displayed in your menu, ProductName.

  8. From the Key column menu, choose ProductID.

  9. In the Link field, enter the link you wish to use for each menu item. If you have used DataAssist to create product details pages, you would likely want to link to them. In this situation, follow these steps.

    How to create a link to a DataAssist details page:

    1. Select the browse icon and choose your details.php page. This name may vary based on your DataAssist options.
    2. Append ?ProductID= where ProductID is the key column you selected above.
    3. Click the Add to link icon and choose the ProductID option.
    4. For example, details.php?ProductID=[ProductID]

  10. Under Filter & Sort, choose ProductCategoryID for Filter.

  11. From the adjacent select list, choose Nested.
    Selecting Nested will filter the menu items based on their category ID.

  12. Sorting is optional.


  13. Click Finish.


  14. Click Finish.

  15. Optionally, check the box and enter a new name if you want to be able to use this preset in the future.


  16. Regardless of whether you save the preset, click Finish.


  17. Click Finish.

  18. Save your page. (Ctrl + S or Cmd + S)

  19. Go to File > Preview in Browser to preview the page in your selected browser.
If you are using a remote web server and database for testing, you may need to upload your files to your server before previewing the dynamic links in your browser.

arrow downModify the dynamic menu items

Once you have created a dynamic menu, you can modify the settings from the CSS Menu Writer interface in Dreamweaver.

  1. Select the menu in design view.

  2. From the the Properties Inspector, click the Edit Menu button.


  3. Select the dynamic menu option you wish to edit, make changes, and click Finish.

arrow downReviews and comments

Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.

Sign in to add comments
rating
rating

: 6 Years, 10 Months, 3 Weeks, 6 Days, 13 Hours, 27 Minutes ago

Pity you only support PHP. There are people who may not like using PHP but use.Net and ColdFusion for example.

: 7 Years, 6 Months, 2 Weeks, 6 Days, 21 Hours, 36 Minutes ago

Can this use MySQLi recordset?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.