Web Workshop: How to publish database content on the web.

Online catalogues are the foundation of e-commerce. Simon Bisson shows you how to create a simple catalogue from the contents of a database.

Building web pages is easy enough, these days. You can walk into any shop selling software, pick up a copy of FrontPage, and have your first web site on the Internet in hours. Using it you can add more pages, updating your content, as well as adding DHTML and other effects. However, after a while, that’s not enough. Web pages shouldn’t be just vanity sites only visited by accident – they should be able to deliver something that brings people to your site.

E-commerce is in every newspaper and business magazine, as the “dot com” economy keeps growing. It’s here that complex web applications are building new businesses and making online millionaires. Unfortunately you’re not going to be able to do that with 20MB of free web space from a free ISP, as a full-blown dot com will require many millions of dollars of investment in hardware and software. Free web space rarely comes with databases space and the CGI or server scripting tools needed to create dynamic web applications. However you can make a start at turning your free space into a small e-business, by going back to the roots of e-commerce: the online catalogue.

The first e-commerce sites were just simple catalogues. Web pages would show images of products, together with detailed descriptions. You could visit them, see what was available, and then make purchases by email, phone, or even good-old mail order. And the web sites had a big advantage over a traditional catalogue, as they allowed their owners to add new products as soon as they arrived – and remove products that had sold out.

The first online catalogues were hand coded, using HTML templates, which were then filled with content. You can still use these techniques, and they’re suitable for a small business with a few products. However maintaining a site full of manual templates can be a tedious business – especially if you’re running a site with hundreds of different products, and are using databases and spreadsheets to manage them.

An alternate approach is to publish your content directly from a database, using a web design tool to create templates that are automatically filled. You can use a specialised tool for this – a visit to TUCOWS will help you find one – or you can use the database publishing features of a web site publishing tool, or even your database itself.

NetObjects Fusion is a WYSIWYG web page design tool, intended for use in small businesses. One of its main features is the ability to take the contents of a database, and turn it in to a well-designed set of static HTML pages. We’ve recently included version 4.0 of Fusion on the Super CD, so we’re using it to show how you can create a simple web site from a database.

It’s easier to show you how to create a site in Fusion, than to describe it – so you’ll see an example of how to create a database connection and a template page in this month’s walkthrough. We’re using the Northwind sample database provided with Access 97 to create a simple site. You can then use these techniques together with your own databases to create your own sites.

However the key steps are simple enough:

  • Create a page
  • Add a data connection object to the page. This can be to Fusion’s internal data store as well as an external ODBC data source.
  • Choose an unique indexing term to create an index list
  • Design the output page, choosing the fields you want to use.
  • Layout the page, resizing data elements as required.

Once you’ve created a set of stacked pages, all you need to do is hit the “Publish” button to transfer your site to your web space. Whilst we’ve produced a simple product query page that allows you to see stock levels of particular products, this is only a sample of what you can do with web-database publishing.

Once you’ve created a data-publishing template using Fusion’s stacked pages, all you need to do to update your site is re-run the Fusion publication process. Just make sure that you set it up to publish its “changed assets only”, as otherwise you’ll find the whole site being updated – which can be a slow process! You won’t be able to automate the publication process, so you’ll need to remember to run it every time you make changes to your database – as there have been cases where companies have been held liable for out-of-date information on their web sites.

Next month we’re going to look at how you publish a web site from a database, and how you can work with the HTML created by databases. We’ll show you how to create a web site directly from an Access database, as well as taking a look at what some other database tools can offer.

Walkthough

All you need to start creating a data-driven web site in Fusion is a single web page. You can choose a site style that will be used to give all your pages a consistent look and feel.

In Fusion’s page layout view choose the Add Data List icon from the Fusion Advanced Tools toolbar, and draw an area on the page. Fusion will then check to see if you want to use internal or external data sources.

If you choose an external data source you can use Fusion’s built-in connection tools (which support most common databases) or set up an ODBC connection to a database. ODBC connections can be complex to debug, so be careful if you choose this option.

You can then choose the fields you will use to navigate through the resulting database generated pages, and what order they’ll be displayed in. Here we’re choosing the English language product field, with an alphabetic sort.

Once you’ve chosen the index fields, you can then start to layout your result pages. Instead of creating a separate page for each database entry, all you need to do is design a template that will be filled when your site is published.

You can use Fusion’s layout tools to format your results template – even to the extent of adding DHTML effects and functions to your results.

Previewing your pages before publishing

Fusion 4.0 isn’t able to show the content of a set of database-driven pages until they are published – so you need to take care of the layout of your template pages.

There’s one big problem with Fusion’s stacked pages. As Fusion 4.0 is a tool for publishing HTML from a set of objects stored in an object-oriented database, and it just stores a set of database generated pages as a database query, there’s no way of actually seeing the contents of a set of stacked pages until they’ve been created. In order to make sure that the fields you’ve included in your pages are the correct size, it’s a good idea to regularly preview the pages you’re creating. This will generate a temporary local copy of a site, ready for testing with your favourite browser.

 

How to publish database content on the web
Home
Web Workshop