RATING: Intermediate
PLATFORM: Windows & Mac
VERSION: FileMaker 5.5 or higher
TECHNIQUE FILES: sessions_orders.fp5, sessions_products.fp5, index.lasso
DOWNLOAD: Lasso Professional 5 < http://www.blueworld.com/Lasso5/LassoPro/evalRequest.lasso >
You can increase speed and time to market on your FileMaker Pro web-enabled solutions by using Lasso Professional 5. When using FileMaker Pro as the back-end database for your internet, intranet or extranet, Lasso Professional 5 has several key features that will greatly aid the development process and ensure a richer end-user experience.
In this article, I create a basic shopping cart utilizing the key elements sessions, maps and arrays. For illustration and simplicity purposes, I have limited my shopping cart solution to ordering products.
Before we begin, make sure you own or have downloaded an evaluation copy of Lasso Professional 5 from BlueWorld.
< http://www.blueworld.com/Lasso5/LassoPro/evalRequest.lasso >
After defining the basic terminology, I will show side-by-side a standard method of creating a shopping cart vs. a more elegant way of creating a shopping cart using sessions, maps and arrays.
Sessions, Maps and Arrays
Sessions allow a web server or middleware server to track visitors at a site. From the moment a user visits a site and is assigned a session identification code, the server is able to track everything that user does -- every web page that is visited, how long the page was visited, every action taken (search, edit, update, etc.), every link that is clicked, etc. After login to a secure area, sessions are used instead of either passing a username and password from page to page or requiring the user to log into every new page viewed.
Lasso Professional 5 uses Lasso Dynamic Markup Language (LDML) tags to initiate and track a user session. When discussing sessions in this article, I am referring to the Lasso Professional 5 feature being used with the visitor of the web site within that one session visit.
Think of a Map as a mini database that can hold data that relates to an ID. It may be helpful to also think of a Map consisting of rows and columns or fields and records which typically hold common information, such as a list of products and their associated properties. A Map is self-contained data that does not necessarily refer to a particular position.
Arrays, unlike Maps, store data against a position. An Array can store a wide variety of data that can be called upon as needed, often referred to by a unique identifier. It may be helpful to think of an Array as a row of data in Excel or a record in FileMaker Pro.
A Map may be used to hold a list of Array values. When used in combination with Maps, Arrays can greatly enhance functionality.
Setting the Scenario
Your client would like to sell products on the internet but demands the following:
1. The current FileMaker Pro database of products must be used.
2. Web Site speed is a priority.
3. FileMaker Pro speed is a priority.
Essentially, you must create a basic product search mechanism with basic shopping cart functionality utilizing a FileMaker Pro product database without bringing FileMaker Pro to a crawling halt. The key to achieving this is to avoid requesting too much data from FileMaker Pro too often. Avoid loading FileMaker Pro up with irrelevant data.
At the same time, as a developer, you don't want to worry about maintaining navigational links for your web site in order to remember what is in the current user's shopping cart.
What to do? The solution is obvious, isn't it? Use Sessions, Maps and Arrays! :-)
Traditional Solution vs New Solution - Product Search
Using Lasso, a developer would be inclined to use an [Inline] search to output the products via the [Records].[/Records] LDML tags. But this has a big draw back - speed. Each time the user searches the product catalog, Lasso requests the results from FileMaker Pro.
Instead of the traditional [Inline]-[Records] approach, maximize the first search that the user performs by loading all of the products into a [Map] that is stored within a [Session] on the Lasso server for that user. On each subsequent search, the user is accessing the [Map], and not requesting data from FileMaker Pro. Load restrictions are minimized resulting in speedier web access and resulting in speedier access of data by desktop users in the company too. Money is saved by reducing the number of FileMaker Pro Unlimited RAIC machines in the web hardware solution.
Traditional Solution vs New Solution - Shopping Cart
Traditional shopping cart solutions make heavy use of database tables to store products being added to a cart. Each product is stored as an Product ID against an Order ID which is related to the shopper. The result is a record being added to an order line items database for each product ordered -- even if the transaction is never completed. The result is a lot of wasted time, and a lot of orphaned orders if the user decides to not complete the transaction. In short, a lot of mess to clean up!
Again, I suggest using the [Session] feature. Store each of the products that a visitor wishes to purchase within a [Session]. Only when the visitor decides to place the final order is the order written to the database.
Once more minimum load is placed on the FileMaker Pro solution. Speed is key.
The Technique Files
I have provided three technique files to illustrate the use of Sessions, Maps and Arrays with Lasso Professional 5 and FileMaker Pro. These files include index.lasso, sessions_orders.fp5, and sessions_products.fp5.
Please open the index.lasso file with your favorite text editor and note the comments that I have provided throughout the HTML and LDML that explains exactly what is occuring.
Summary
Combine the features discussed above within your web application you will only interact with FileMaker Pro on the following occasions within a single visitor session:
- Getting Product List (once)
- Product Order (once per product upon completion of order)
as opposed to:
- Getting Product List (each time the visitor searches for a product)
- Product Order (each time the visitor places a product in the cart, changes the quantity of the product ordered, deletes a product ordered, etc.)
The visitor can be searching for products, adding and subtracting products from their basket/cart and they have only touched FileMaker Pro once within a 20 minute [Session].
These features can obviously be used in any variation. Once you have played around with the mini one page cart, feel free to give it variations of product searches within the [Inline], add some conditional statements and even break up the code to utilize the Lasso [Include] feature for easy code navigation.
Happying Lassoing!
Duncan Cameron is a Lasso Developer and author. He solemnly swears that if you have fun developing a Lasso solution, your clients will have fun using it. Email him at <djcameron@lassodevelopment.com>