Dave's FileMaker® Pro Newsletter
FileMaker Data Parsing:
Separation, Commonality, and Distinction

by Dave Dowling, FileMaker database consultant

<< Page 2 | Page 4 >>

Hello, World!

Well, enough background; let's dig into CDML! Before we continue, let me assure you that we're not going to exhaust the capabilities and functions of CDML in this article. What you're about to learn is how to create a very basic CDML web page. This offers web database beginners the opportunity to get off the ground with CDML, but little more. I'll start by showing you a very basic HTML page, upon which we'll build as this article continues. Here it is:

<html>
<head>
<title>
My Web Page
</title>
</head>
<body>
Hello, World!
</body>
</html>

 
FileMaker Pro Consulting & Training
 
 

· FileMaker Consulting, Training & Programming

 
 

· 15+ Years' Experience

 
 

· Expert FileMaker Training Online

 
  · FileMaker Calendar Solution free to download and try  
spacer
  Contact us for a free, no obligation consultation  
spacer

This code produces a web page with the phrase "Hello, World!" in plain text on the page. When this page is displayed in a web browser, the header bar will show the title "My Web Page". Keep this structure in mind; it's about as basic as a web page gets. To test it, just copy the code and paste it into a text document in your favorite text editor. Save the file as helloWorld.html, and save it on your computer's Desktop. Then open your web browser and drag your newly created file's icon into your web browser. This action will open your new web page.

The World's Simplest FileMaker Database?

Now let's create the least complicated FileMaker database possible. Create a new database file in FileMaker Pro, and call it Friends.fp5. We'll pretend that we're creating a database that will hold the first names of some people we know. Create a single text field in this database, and call it FirstName. Now create a layout called "web", and add your FirstName text field to that layout. Why create this layout? In order to be most efficient, as well as to be as security-conscious as possible, web pages that include FileMaker data require the specification of a layout, and any fields that you add to your FileMaker web view must be on that layout. If your field is not on this layout, you'll get an error when you try to use it in your web page. This is one of the most common problems developers have when creating CDML pages, so keep it in mind. Make it the first thing you check if you get errors while testing your CDML pages.

Now that you've created your database, go ahead and add three new records. In the first, enter the first name "Sally" in your FirstName field. In record two, enter "Charlie", and in record three, enter "Lucy". We now have some data that we can web share.

The FileMaker Form Element: Gateway to the Database

Now we'll create a few very simple web pages. First, we'll create a page called "startHere.html", which will contain the code that will open a web version of our new database. Create a plain text document in your favorite text editor, and paste the following code into the empty text document:

<html>
<head>
<title>
My First FileMaker Web Page
</title>
</head>
<body>
<FORM ACTION="FMPro" METHOD="POST">
<INPUT TYPE="hidden" NAME="-DB" VALUE="Friends.fp5">
<INPUT TYPE="hidden" NAME="-Lay" VALUE="web">
<INPUT TYPE="hidden" NAME="-Format" VALUE="friendsList.html">
<INPUT TYPE="hidden" NAME="-Error" VALUE="error.html">
<INPUT TYPE="submit" NAME="-FindAll" VALUE="Click this button to open Friends.fp5">
</FORM>
</body>
</html>

Save this HTML document, and the remaining HTML documents in this lesson, in your FileMaker Web folder. To find your Web folder, simply locate your FileMaker Pro application. The Web folder is in the same directory as the FileMaker Pro application.

Note that this is very similar to the "Hello, World!" web page we created earlier, except that the title is different, and that the text "Hello, World!" in the body section has been replaced with a form section. This form section begins with the tag <form action="FMPRO" method="POST"> and ends with the closing tag </form>. This section contains the commands our web page needs in order to open a web version of our Friends.fp5 database. Here's what's happening, line by line:

<FORM ACTION="FMPro" METHOD="POST">

This line starts our form. As you use CDML, you'll create many forms. For our purposes, let's just say that forms are used to request, add and edit data in databases. I won't bore you with why, but METHOD will always be "POST" in CDML forms. You can safely start all of your CDML forms with this line. It amounts to "Hello, I'm a form and I'm about to post a request of some sort to your database."

<INPUT TYPE="hidden" NAME="-DB" VALUE="Friends.fp5">

This is a hidden form element (one that the web user can't see on the published web page) that tells FileMaker which database (-DB) to open.

<INPUT TYPE="hidden" NAME="-Lay" VALUE="web">

This hidden form element specifies which layout (-Lay) in the database to access for data. Remember, only fields on this layout can be displayed on the web page that this form calls.

<INPUT TYPE="hidden" NAME="-Format" VALUE="friendsList.html">

This element specifies the format page, which is the web page we want this form to open. We'll create the page friendsList.html shortly.

<INPUT TYPE="hidden" NAME="-Error" VALUE="error.html">

If there's a problem with our request, we don't want our web user to be confused about what's going on. To avoid that scenario, we send the user to an error page instead of the format page. Think of these two options as success (format) and failure (error) pages. If the web user's request is successful, we send them to the format page. If their request fails for any reason, we send them to the error page, in this case, error.html. We'll create this page shortly.

 

<< Page 2 | Page 4 >>

 

Copyright 2003, Dave Dowling. All rights reserved.

 
 
 
  FileMaker® Pro Data Parsing
Convert that tangled web into usable data!
 
FileMaker Web Publishing
CDML, Lasso (LDML) & Instant Web Publishing (IWP)