Tutorial - Custom Template for Summary Report

You can use Custom Template to display your summary reports in your own layout.

Note Before reading this tutorial, please read Custom Templates and understand the concept of Custom Template first.

In this tutorial we will show you how to create a Custom Template for exporting a group from a summary report. We will use the demo project for demonstration.

We'll create a template for a summary report similar to that in Tutorial - Summary Report. Refer to the tutorial to create another view, the only difference is that we'll show some customer information in the export version, so we add some more fields from the customers table in the view:

Then we create the same Summary Report as in above tutorial, we name it as, say, "Sales By Customers 2". Note that there are 2 grouping fields:

When you select the fields, you do not need to select above additional fields (ContactName, ContactTitle, Address, City, Region, PostalCode, Country, and Phone) that you don't normally show in the report. Alternatively, you can unselect them in the Show column of Field Setup page after you have created the report.

We also enable Extended Search for the OrderID so we can select an order from the report before we export it:

 

Steps to Create the Custom Template

1. Loading PHPMaker

Open PHPMaker and then open the demo project.

2. Add the Custom Template

Select the "Sales By Customers 2" report, then click the Code (Server Events, Client Scripts and Templates) tab and expand on the Custom Templates node. You will see that there are many different sections for the custom template, as shown in the diagram below.

Each template refers to a different part of the report, you can enter your own HTML for them. (See Custom Template Tags for the meanings of the tags with triple curly brackets.)

Note When exporting summary reports with Custom Template, only tables with class ew-table will be exported. Make sure you put your content in tables with class="ew-table". For PHPWord and Dompdf extension (see Extensions), by default tables are exported with border, if you want no border, add the class no-border to the table.
Template Name Sample Code
CustomTemplateHeader
Note Since the fields CompanyName, Address, City, Country, ContactName are not shown in the report, we cannot use Custom Template Tags to show them. (Remember that Custom Template is re-arrangement of existing HTML fragments.) However, since the report records are passed to the template as additional data, we can make use of dbvalue tag to display the values.
CustomTemplateGroupHeader2
Note We use CustomTemplateGroupHeader2 instead of CustomTemplateGroupHeader here because we want to show the sum of Extended Price in the order. And OrderID is the second grouping field of the report.
CustomTemplateBody
CustomTemplateGroupFooter2
Note We use CustomTemplateGroupFooter2 instead of CustomTemplateGroupFooter here because we want to show the sum of Extended Price in the order. And OrderID is the second grouping field of the report.
CustomTemplateFooter

After entering the sample code in the corresponding templates above, click OK to finish.

3. Generate scripts

Go to the Generate tab, click the Generate button to generate scripts.

4. Run the application

Browse the generated site, go to "Sales by Customer 2" report, select an order in the Extended Search panel, we'll see:

Now click Export -> Printer Friendly or Export to PDF to see the result:

 

 ©2002-2025 e.World Technology Ltd. All rights reserved.