Tom Muck

Alpha Dog Blues Band
Home page
All articles
All Extensions | Extension News | Extension FAQs | Customer Login
Books authored or co-authored by Tom Muck
Extensions, books, and other products | Customer Login
Your current cart contents
Tom-Muck.com Blog | CMXTraneous Blog | Flash Remoting Blog
About the site

Blog

Tom Muck's BlogTom Muck's Blog

News and Views

Evolution of the Horizontal Looper for Dreamweaver

Monday, August 23, 2004 8:29:29 AM

My most popular extension has been the Horizontal Looper extension, featured on the MM Exchange as well as several books like UltraDev 4 for Dummies, The Joy of Dreamweaver MX, UltraDev 4: A Beginner's Guide, and others. I developed it originally for UltraDev 1, but created updates for UltraDev 4 and Dreamweaver MX. I created some new code that allows vertical and horizontal looping.


The Horizontal Looper was originally conceived for the program Drumbeat 2000 from Macromedia. Drumbeat had a Looper, which was similar to a Dreamweaver repeat region, but lacked horizontal capabilities, just like Dreamweaver. Drumbeat had an extensibility layer also, but it was much more accessible to the average user than the extensibility layer of Dreamweaver. Anyway, when Drumbeat was discontinued, I used the Horizontal Looper as a way to learn how to build extensions using the server behavior mechanism of UltraDev.

The Horizontal Looper essentially creates a table on your page to display dynamic content. Unlike the repeat region, the Horizontal Looper has to create a table so that it can display columns of data rather than just repeat your data. The repeat region uses a simple while loop (or a <cfloop> in ColdFusion) to display data. The Horizontal Looper has to keep track of which column, which row, and which record is currently being displayed. The goals of the extension were to:

  1. Maintain compatibility with all existing DW/UltraDev extensions, like the recordset navigation (paging) behaviors and the recordset stat variables.
  2. Maintain the design-view advantages of Dreamweaver: allow the end user to modify the table that is generated.

Because of these requirements, the scripting could not use simple print or echo statements, like this:

<?php echo("<table><tr><td>");?>

or this:

<% Response.Write("<table><tr><td") %>

I originally created versions to work in all UltraDev server models. When the PHAkt extension was released as a free server model for PHP users, I created a PHP version as well.

Unfortunately, Dreamweaver MX added complexities to the mix: a completely new server behavior mechanism was introduced for the new server models: PHP/MySQL, ASP.NET, and ColdFusion (completely rebuilt for DW MX). This new mechanism rendered many old extensions incompatible. I was able to salvage the ASP and JSP versions, but PHP and CF were not so easy. I eventually created a PHP version using the new server behavior mechanism, and still maintaining my goals of compatibility with recordset paging and design-view. I also wrote a tutorial on how to easily do horizontal/vertical looping using ASP.NET. That article is available at Community MX.

Other companies have since released "horizontal looper" extensions. I never did trademark the name, so they are free to use it.

The ASP version still suffers from a problem with table cells when the last row does not have the same number of columns as the other rows (say 2 cells in the last row of a 3 column table). This bit of code inserted before the closing </tr> tag will fix that:

<%
While startrw <= endrw
Response.Write("<td>&nbsp;</td>")
startrw = startrw + 1
Wend
%>

Which brings me to the ColdFusion version. Unfortunately, I have not been able to successfully create a ColdFusion version of the server behavior that is works in DW MX consistently. There are "issues", mostly due to bugs with Dreamweaver's selection mechanism and also with collisions with built-in DW server behaviors. However, I have come up with some code that allows both horizontal AND vertical looping. Check out this page, and play with the values. The code allows any number of rows or columns, and the repeat can be either horizontal or vertical. The code works with the existing Dreamweaver paging server behaviors, and also with my own Recordset Navigation Suite. The code is commented inline, and available as a download here. Change rs_ to yourRecordsetName_ to use this on your own pages. The code also includes the paging code for the recordset navigation bar and Links List, and works with the Northwind database that everyone has. If you use MySQL and don't have access to Northwind, I translated Northwind to MySQL here.

You can view the code here or download it here.

The code will eventually be turned into a server behavior for ColdFusion and PHP.

Category tags: Community MX, Dreamweaver, ColdFusion

Before posting comments or trackbacks, please read the posting policy.

Full Blog Calendar

Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
About | Privacy Policy | Contact | License Agreement | ©2002-2024 Tom Muck | Dreamweaver Extensions