Chapter 2 Getting Started with PowerDynamo


Creating a template

In this tutorial you create an HTML template that includes a SQL query. A Web client accessing this template will receive the formatted results of the SQL query.

Steps To add a template to your Web site:

  1. From Sybase Central, connect to the Dynamo Demo Web site.

  2. In the left pane, click the Site folder. You may have to expand the Web site container to do this.

  3. In the right pane, double-click Add Template.

  4. Enter a name for the template; for example, Products . Do not use any spaces. Click Next.

  5. Enter a description, for example, A test template . Click Next.

  6. If you have more than one connection type you will be asked to pick a connection.

  7. On the Add SQL Query page, click Select. The SQL Query Editor is displayed. The SQL Query Editor is a tab window that allows you to manipulate and enter clauses of the SELECT statement. The Test tab allows you to Test the query before continuing.



  8. Select HTML as the document type.

  9. Select Table with Headings from the list of supplied formats.

  10. Click Finish to add the template to the Web site.

You can display the HTML in the Sybase Central syntax-highlighting editor. The editor color-codes HTML tags, SQL syntax, and script syntax, making editing and viewing of templates easier.

Templates are created with default extensions of .stm. We recommend that you keep this extension for all your templates.

The query and formatting instructions are included in the HTML as specially formatted HTML comments.


Steps To view the template output:

  1. Right-click on the template.

  2. Select View Output from the pop-up menu to display the results of the query in the Sybase Central syntax-highlighting editor.


The output displays the formatted results of the query instead of the query and the formatting instructions.

You can also send the output to your browser by selecting Browse Output from the pop-up menu. For more information see "Viewing template output in a Web browser".

Steps To edit the template using the Sybase Central editor:

  1. Double-click on the template to display it in the Sybase Central highlighting editor.

  2. Add a paragraph in front of the table. For example, you could enter the following text after the </H1> tag that marks the end of the heading:

    Table of Products


  3. Click the database icon on the toolbar to save the script to the database.


Note  

Save templates to a database
Make sure that you do not save the template to a file, but save it to the database.

How dynamic content is held in HTML templates

Dynamic content is embedded in an HTML template as HTML comments. This allows you to use Web page authoring tools to refine the static components of your Web pages without interfering with the dynamic content.

An HTML comment is marked by the following delimiters:

<!-- 

-->

A SQL statement is identified by a special comment marker, as follows:

<!--SQL
select prodname, price
from product
-->

A SQL statement with formatting instructions is embedded as follows:

<!--SQL 
select prodname, price from product -->
<!--FORMATTING-->
( table instructions here )
<!--/FORMATTING-->

A script is embedded as follows:

<!--SCRIPT
document.WriteLn ( "Hello world" ) ;
-->

For more information see the chapter "Dynamo Tags" in the PowerDynamo Reference.

 


Copyright © 1999 Sybase, Inc. All rights reserved.