Difference between revisions of "Create a Compound Document Template"
imported>Aeric |
imported>Aeric |
||
Line 4: | Line 4: | ||
:;Create a single document composed of multiple parts: | :;Create a single document composed of multiple parts: | ||
:: For example, when printing an order form, logo images and boilerplate could be in the first and last sections, the middle section could contain the logic for looping through order items to create a table. A designer working on the layout of the headers and footers could then do so without regard for the logic--and the logic could be reused in different templates. | :: For example, when printing an order form, logo images and boilerplate could be in the first and last sections, the middle section could contain the logic for looping through order items to create a table. A designer working on the layout of the headers and footers could then do so without regard for the logic--and the logic could be reused in different templates. | ||
::(See [[#ex1|Compound Template Example: A Two-Part Order Form]].) | |||
:;Create a single file composed of multiple documents: | :;Create a single file composed of multiple documents: | ||
Line 29: | Line 30: | ||
'''Considerations''' | '''Considerations''' | ||
:* {{TBD|Is the compound template created by reference or by value-copy? (What happens when a new version of a component is uploaded?)}} | :* {{TBD|Is the compound template created by reference or by value-copy? (What happens when a new version of a component is uploaded?)}} | ||
<span id="ex1"></span>'''Compound Template Example: A Two-Part Order Form''' | |||
This example breaks the [[Print Templates#Sample Print Template for an Order Invoice|Sample Print Template for an Order Invoice]] into three parts, so that the processing-logic is confined to a single module: | |||
Header Component: | |||
:<syntaxhighlight lang="xml" enclose="div"> | |||
<html><head> | |||
<title></title> | |||
<style> | |||
div { | |||
padding-top: 5px; | |||
padding-bottom: 5px; | |||
padding-right: 5px; | |||
padding-left: 30px; | |||
border: 3px; | |||
margin-top: 5%; | |||
margin-right: 40%; | |||
margin-bottom: 5%; | |||
margin-left: 5%; | |||
} | |||
</style> | |||
</head><body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> | |||
<div style="width:100%"> | |||
<img width="100" height="100" src="http://justanothermobilemonday.com/Wordpress/wp-content/uploads/2009/10/android-robot-logo2.jpg" alt="Company logo" /> <---- Company Logo Here<br/> | |||
<font size="5"><b>$company.name</b></font><b><br /> | |||
<br/> | |||
$company.street <br> | |||
$company.city, $company.state, <br> | |||
$company.country - $company.zip | |||
<br> | |||
(Phone): $user.phone | |||
<hr width="100%" size="1" /> | |||
<br /> | |||
<h2 align="center">Order<b> Invoice</b></h2> | |||
<p></p> | |||
<p align="center"><b>Invoice Date:</b> $Orders.date_created </p> | |||
<br/><br/> | |||
<b><u>Bill To: </u></b><br /> | |||
<font size="2">$Orders.account.name - $Orders.account.number</font></b> | |||
<br />$Orders.account.street<br /> | |||
$Orders.account.city, $Orders.account.state, <br> | |||
$Orders.account.country - $Orders.account.zip<br /> | |||
(Phone): $Orders.account.phone <br /> | |||
<br /> | |||
<br /> | |||
<b>Invoice #: $Orders.order_number <br /> | |||
</b> | |||
</p> | |||
</syntaxhighlight> | |||
Logic Component: | |||
:<syntaxhighlight lang="xml" enclose="div"> | |||
<table border="1" cellpadding="5" cellspacing="0" width="600"> | |||
<tbody> | |||
<tr> | |||
<th>Quantity</th> | |||
<th>Product </th> | |||
<th>Unit Price</th> | |||
<th>Amount</th> | |||
</tr> | |||
</tbody> | |||
#foreach( $OrderItems_record in $OrderItems ) | |||
<tr> | |||
<td width="350">$OrderItems_record.item_quantity</td> | |||
<td width="100" align="CENTER">$OrderItems_record.related_to_ProductInventory.product_name</td> | |||
<td width="100" align="CENTER"> $OrderItems_record.item_price</td> | |||
<td width="100" align="CENTER"> $OrderItems_record.total </td> | |||
</tr> | |||
#end | |||
<tr> | |||
<td colspan="2"> </td> | |||
<td style="border: solid 1px #000000;" align="Right">Sub Total</td> | |||
<td style="border: solid 1px #000000;" align="center">$Order.grid_comptn_f5631e34b39f4ba39a98559c7215a3b4</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2"> </td> | |||
<td style="border: solid 1px #000000;" align="Right">Tax</td> | |||
<td style="border: solid 1px #000000;" align="center">$Orders.grid_tax_f5631e34b39f4ba39a98559c7215a3b4</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2"> </td> | |||
<td style="border: solid 1px #000000;" align="Right">Shipping</td> | |||
<td style="border: solid 1px #000000;" align="center">$Orders.grid_shipping_f5631e34b39f4ba39a98559c7215a3b4</td> | |||
</tr> | |||
<tr> | |||
<td colspan="2"> </td> | |||
<td style="border: solid 1px #000000;" align="Right"><b>TOTAL AMOUNT DUE</b></td> | |||
<td style="border: solid 1px #000000;" align="center"><b>$Orders.grid_net_total_f5631e34b39f4ba39a98559c7215a3b4</b></td> | |||
</tr> | |||
</table> | |||
</syntaxhighlight> | |||
Footer Component: | |||
:<syntaxhighlight lang="xml" enclose="div"> | |||
<br /><br /> | |||
Payment Due upon receipt<br /> | |||
Thank you for your business! | |||
</div> | |||
</body> | |||
</html> | |||
</syntaxhighlight> | |||
<!-- | <!-- | ||
::(See [[#ex2|Compound Template Example: Combining Multiple Documents]].) | |||
<span id="ex2"></span>'''Compound Template Example: Combining Multiple Documents''' | |||
::(See [[#ex2|Example: Combining Multiple Documents]].) | |||
<span id="ex2"></span>'''Example: Combining Multiple Documents''' | |||
:-- | :-- | ||
--> | --> |
Revision as of 21:42, 23 May 2012
A compound print template lets you combine multiple templates into a single output file.
Compound print templates have multiple uses:
- Create a single document composed of multiple parts
- For example, when printing an order form, logo images and boilerplate could be in the first and last sections, the middle section could contain the logic for looping through order items to create a table. A designer working on the layout of the headers and footers could then do so without regard for the logic--and the logic could be reused in different templates.
- (See Compound Template Example: A Two-Part Order Form.)
- Create a single file composed of multiple documents
- When processing an order, you might need to generate an inventory-pull sheet, a customer invoice, and a shipping sheet. Each of those would be a separate template, but they can all be printed at one time in a single, compound document.
- __TBD: Is it possible to combine different kinds of templates?__
- Any combination of the above
- The output of the compound document is a single file. What goes into that file is up to you. You can create any combination of documents and document components you want, using Print Template Variables to access information from the record you are processing, any records it looks up to, and any records that are related to it.
- Learn more:
To create a compound print template:
- Go to {object} > Customize this Object > Print Templates
- Click [New Template]
- Specify Type as Compound
An [Add Template] button appears. - Click the button to add a new template to the list of components
To remove a component template:
- Select the empty row at the top of the template selection field.
When saved, that row is removed from the compound template.
- Select the empty row at the top of the template selection field.
Considerations
- __TBD: Is the compound template created by reference or by value-copy? (What happens when a new version of a component is uploaded?)__
Compound Template Example: A Two-Part Order Form This example breaks the Sample Print Template for an Order Invoice into three parts, so that the processing-logic is confined to a single module:
Header Component:
- <syntaxhighlight lang="xml" enclose="div">
<html><head> <title></title> <style>
div { padding-top: 5px; padding-bottom: 5px; padding-right: 5px; padding-left: 30px; border: 3px;
margin-top: 5%; margin-right: 40%; margin-bottom: 5%; margin-left: 5%;
}
</style>
</head><body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<img width="100" height="100" src="http://justanothermobilemonday.com/Wordpress/wp-content/uploads/2009/10/android-robot-logo2.jpg" alt="Company logo" /> <---- Company Logo Here
$company.name
$company.street
$company.city, $company.state,
$company.country - $company.zip
(Phone): $user.phone
Order Invoice
Invoice Date: $Orders.date_created
Bill To:
$Orders.account.name - $Orders.account.number
$Orders.account.street
$Orders.account.city, $Orders.account.state,
$Orders.account.country - $Orders.account.zip
(Phone): $Orders.account.phone
Invoice #: $Orders.order_number
</syntaxhighlight>
Logic Component:
- <syntaxhighlight lang="xml" enclose="div">
- foreach( $OrderItems_record in $OrderItems )
- end
Quantity | Product | Unit Price | Amount |
---|---|---|---|
$OrderItems_record.item_quantity | $OrderItems_record.related_to_ProductInventory.product_name | $OrderItems_record.item_price | $OrderItems_record.total |
Sub Total | $Order.grid_comptn_f5631e34b39f4ba39a98559c7215a3b4 | ||
Tax | $Orders.grid_tax_f5631e34b39f4ba39a98559c7215a3b4 | ||
Shipping | $Orders.grid_shipping_f5631e34b39f4ba39a98559c7215a3b4 | ||
TOTAL AMOUNT DUE | $Orders.grid_net_total_f5631e34b39f4ba39a98559c7215a3b4 |
</syntaxhighlight>
Footer Component:
- <syntaxhighlight lang="xml" enclose="div">
Payment Due upon receipt
Thank you for your business!
</body> </html> </syntaxhighlight>