|MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA|
Working with Multiple Content Sources in GoLiveby Derry Thompson
It will happen. One day you'll encounter a situation where you need to manipulate data from multiple content sources, such as for an e-commerce site. While GoLive allows you to add multiple content sources with ease, extracting multiple records from one source (based on multiple records from another source) is beyond the scope of its current GUI. However, with some cutting, pasting, editing, and using nested loops, you can manipulate data from multiple content sources.
The following is a simplified, yet fairly typical data structure. There are three data tables: one containing client information, another product details, and the third containing the order details. Each is linked by common fields.
The order table contains information referenced from both the client table (
In this example, we're going to extract the required data from one content source and use that data to extract additional data from other content sources.
Begin by building a fairly standard reporting page such as the following. Add a content source that references the client data table, and then use a repeat rows object to build the report.
This will look like the picture below when viewed live.
So far, only data from the table named clients can be extracted. In order to get the data from a second table, another content source must be added. To do this, add another content source in the header, call it "
There are now two data sources specified (
Next, switch to source.
Locate the orders content source in the head section. It should look like the following:
Select it, then cut it. Now scroll down, and find the clients repeat row container. Paste the second data source inside the first loop--specifically outside the loop for the order section, but inside the loop for the clients.
The order content source now needs to be altered to retrieve orders belonging to the active client in the loop. Add
This will retrieve orders where the "
When viewed live, the report will look like the following:
This can be further expanded. Add another content source in the header, bound it to the products table (naming it '
Switch to source, and locate the code for the content source. It should look like the following:
Select it, cut it, and paste it inside the '
Next, amend it to retrieve a product based on the product code in the listorder content source. Do this by replacing
Switch back to layout mode, and add bindings for the product description and price.
The final report will look like the one below. It merges data from three tables. It produces a list of clients, which in turn lists order transactions belonging to that client, which in turn extracts product information from the product table.
At first glance, it may appear that GoLive's Dynamic Content is not suitable for advanced applications. However, by using nested loops you can expand the capabilities of GoLive's Dynamic Content to extract information from many different data tables. This will allow you to build complex reports and present information in many different formats.
Give GoLive's Dynamic Content a second glance. With a little know-how, it can be more powerful than it initially appears.
Derry Thompson is currently co-owner of GloDerWorks with his partner Gloria Hansen. An active participant in the GoLive community and an avid Mac user, he can be found in various airports using his Titanium G4 Powerbook.
Return to the Web Development DevCenter.
Comments on this article
1 to 4 of 4
1 to 4 of 4