Creating a new Template

(2 posts) (2 voices)

Tags:

No tags yet.

  1. mitchbeatty, Member

    I am having a difficult time following you template example for an invoice. In the user interface for creating a new template there is not any explanation on how to actually create the header, row and footer.

    1. If I name the template "Dealers" for example and place code for the header, row and footer, and save as Dealers how do you call each header row and footer in the report?

    2. Can you explain this fully: select 'dbr.template', '#template' | 'row template code' | 'header template code', 'row template code', 'footer template code', [ 'template_class' | 'none' ]

    What would be in row template code etc.

    This is very confusing.

  2. myDBR Team, Key Master

    1) A template is always designed against a result set (a query). A result set can return one or multiple rows (or none).

    When the result set contains multiiple row (like the invoice rows in the demo / documentation), you often need initialization for the result set (for example for invoice row HTML table headers), you need to show the actual data (invoice rows) and at the end, you need to close the table tags. In a template, you would define the headers in the template header section, put the actual row HTML in the rows section, and then close the table in the template footer section.

    When the result set contains just one row, a template is a simple one-to-one mapping where result set variables will be placed in the template code. In case of just one row returned, you do not need any header or footer sections as you can do all necessary in the row-section.

    You can place also additional HTML to header/footer sections (CSS styles, JavaScript code etc) as these are placed in the reports only once.

    The invoice template example uses three separate templates, one for the header (logo, dates, invoice nbr), one for the rows, and one for the rows footer (implemented as separate template as the data for it comes from separate query).

    2) You can define the template in myDBR templates section, in case you would refer to the template by its name "#invoice_header". This is the most common use of templates.

    The other alternative which you can use (usually if the template is very simple), is to define the template HTML directly in the dbr.template-command ('row template code' would be the equivalent of the templates row-section.

    Take a look at the documentation to see the full code and explanation for the invoice-template example.

    --
    myDBR Team


Reply

You must log in to post.