|
Previous: Web Programming
androPageMost of the programming that we do for web sites follows a simple pattern. The user request comes to the web server, we pull some data from a database, and we display it to the user. This pattern holds true even for operations that do not at first glance seem very similar. A simple export to a CSV file is the same as producing a polished PDF report, you pull it out and give it to the user. The only difference is the display format. Even a page of complex HTML is just another way to display data that was taken from the database. The Andromeda "andropage" feature builds on this idea. If you can spell out the data you want, including some crucial details like filters and ordering, it should be pretty simple to just tell the framework to use some standard output method, like a Smarty template, PDF, CSV, or even a plain vanilla framework-generated dump of the data. Getting StartedFirst, choose a name for your page. It should not be the same as a table, but otherwise use any convention you want. In this example we will use "ex_customers" because we are going to do an example page out of the CUSTOMERS table of the Demonstration Database. Once you have a name, fire up your favorite editor and we will work up "--name--.page.yaml", which should be saved in your applications directory. Here is the complete example of ex_customers.page.yaml: options:
title: Customer Report
table customers:
column customer:
column description:
column amt_order:
compare: between @amt1 and @amt2
column amt_paid:
column amt_balance:
uifilter amt1:
type_id: numb
colprec: 10
colscale: 2
description: Minimum Balance
uifilter amt2:
type_id: numb
colprec: 10
colscale: 2
description: Maximum Balance
Linking To This PageBefore we go into too many details, we will see how to link to this page. You can put this page on your menu in the database YAML file. Here is an example of two placements from the demo database: # ======================================================================
# REPORTS
# ======================================================================
module appreps:
uisort: 400
description: Reports
menu ex_customers:
module: appreps
uisort: 100
description: Customers
menu ex_salestax:
module: appreps
uisort: 200
description: Tax Report
You can link to this page by specifying the "gp_page" parameter in any hyperlink: <a href="http://www.andromeda-project.org/demo/?gp_page=ex_customers"
>A hard-coded link to my example!</a>
You can also supply filter values in the hyperlink. Filter values are explained in more detail below, but for now it is enough to know that if you want to pre-supply them with a link you name the parameters "txt_" + filter name, as in this example: <?php
$url="http://www.andromeda-project.org/demo/";
$parms='?gp_page=ex_customers'
.'&txt_amt1=10000'
.'&txt_amt2=30000';
?>
<a href="<?=$url.$parms?>"
>A hard-coded link to my example!</a>
What the User SeesWhen you link to an androPage, the first thing the user sees is a page requesting his filter values:
When the user clicks on the print button, the default action is to print a PDF report. Notice that the report makes use of the title and displays the filter values:
Controlling The FlowSometimes you do not wish the user to see the first screen asking for filter values. To prevent this, pass in at least one filter value as a parameter. Output ModesSo far androPage supports two output modes:
We are planning the following output modes:
Table of ContentsAndroPage Smarty
Previous: Web Programming
|
