Search
  • Rob Brown

Creating the Gym Member sample

Updated: Apr 15

This article walks through the steps taken to create the Gym Member example as part of the Tag Samples collection.


The goals for this project are as follows:

  • Use multiple data setup files

  • Include at least 1 predefined field

  • Include common utility templates like he-she, his-her, Member and Mr-Ms

  • Include both kinds of dynamic lists (inline and bulleted/numbered)

  • Make everything as simple as possible and easy to copy & adapt


1. Create a folder

This sample will require multiple files that work together. The best way to start is with an empty folder in your local file system. For this article we'll use C:\gym-member. You can create it in the normal way for your desktop, or use Tag.


2. Data setup

Start Tag and ensure the Smart content app is showing. You can change apps using the hamburger icon (3 horizontal lines) next to your name in the top-right area of Tag. Click on the Setup tab in the top-left area of Tag to show the data setup screen.


A file navigation tree displays on the left side. If the Favorites selection is "{show all folders}", you will see all drives and root folders in your file system. Either create the gym-member folder here (using the + tool beneath the tree) or navigate to it.


To make it easy to return here, click on the star icon next to the "gym-member" folder name in the file tree. This will select the star and make this folder a favorite. It will now display in the Favorites dropdown list, and you can choose it as a startup folder using the Manage preferences menu item in the account menu (your name).


Select the gym-member folder and click the + icon to add a data setup document. Click on Select path... to name the new file "member" and click Next. The next screen establishes data ownership using a URI that includes your unique account name in Tag. Accept the default URI by clicking Finish. Your screen should now look like this.



Using the provided toolbar, you can now add fields that relate to a member in the gym (name, contact info, etc.).


For a predefined field use gender and make it a dropdown list. The gym needs a gender for each member (for changing room access, etc.), and also gathers it for a parent/guardian so they can be addressed as Mr. or Ms. last name. The predefined gender field now looks like this.



When adding a field that uses a predefined field, simply select it from the provided dropdown list. At this point the completed member.rng data setup file looks like this.



A quick form preview will ensure all the field labels look right.



Next create a second data setup file called fitness-goals.rng and add fields for goal1, goal2, goal3, plan1, plan2, plan3, measureDate and reward. Use textboxes for goals and larger text areas for plans and reward.


The form preview for this file looks like this.



3. Create template files


After both data setup files are saved click on the Templates tab in the top-left area. Use the + tool under the file tree to create template files.


The first file to create is member-summary.xsl, which will use fields from both data setup files. After creating the file, use the File options menu at the top to open the Import data setup... dialog. Add both data setup files as direct imports and close the dialog. Now you can use those fields anywhere in this document's templates.


Before editing begins, it is helpful to gather common utility methods. If possible try to copy existing ones and tailor them to your data fields. That has been done in the memberHeShe.xsl file that is now within the project folder (note the different file naming standard for shared utility templates).


This file contains these templates:

  • He-She, he-she, His-Her, his-her, him-her - all use the member gender field by default

  • Member, Member-s - use the member's first name in normal and possessive form

  • Mr-Ms - use a gender field to more formally address someone (e.g., parent or guardian)


When a new template file is created, it has a start template which is used to begin a generated document. That isn't needed in memberHeShe.xsl as it only contains utility templates, so delete the start template if one exists. Now you can import these shared utilities into any template file that uses member data.


Back in the member summary document, use the File options menu to open the Import content... dialog. Add memberHeShe.xsl as a direct import. Now when you click the call-template tool on the Logic toolbar you see these options.



4. Edit content


A generated document always begins with the start template. In this example, the member-summary.xsl start template is used.


This document starts with contact information merged into a sentence and table. These are all simple value-of instructions, with a space forced between two adjacent logic bubbles.


Next comes the dynamic lists, but these should only be inserted if at least one goal has been entered. This is handled by creating a template to review goals and protecting it with an if instruction.


Click on the + tool next to the Show template dropdown to create a new standard template called reviewGoals.


Click on the call-template tool in the Logic toolbar and then the Select template to call... menu item. Under the memberHeShe.xsl branch select Member and click the Insert button. This inserts a logic bubble that will insert the member's name. After that type " has goals which include " and get ready to create a dynamic list.


Dynamic lists are used to combine a list of conditional strings in either inline or bulleted/numbered format. The first dynamic list in this example is inline, so click the + add template tool, name it listGoals, click Next and select the Widget template mode. The default option is Combine strings inline, so just click Finish.


A new screen is displayed which allows you to enter conditional strings. Each string is protected by an expression. When the list is generated, only strings that have expressions which return true will be included in the result.


Enter three strings representing each of the three goal fields in the fitness-goals.rng data setup file. The content of each string is a value-of instruction (logic bubble). When done it should look like this.



Note that you have to edit each string using the pencil tool to see the smart content editor, which displays logic bubbles and whatever else goes into each string. You can also select strings for editing using the decision tree graph at the top.


Next insert a call-template to listGoals to complete the sentence " has goals which include " and finish with a period.


Use the same approach for a dynamic numbered list that contains plans to reach the member's goals. In the reviewGoals template and add a new paragraph which contains "[His-Her] plans to achieve these goals are as follows:", where [His-Her] is a call-template.


Since this dynamic list will be numbered, add a new paragraph and click the call-template tool, then select Create new template... which opens the create template wizard. Name the template listPlans, make it a widget template, then set the Widget type to Bulleted or numbered list. Now you can select a numbered list and add conditional strings just like above.


Next, return to the reviewGoals template to add a call-template to the listPlans numbered list. One final sentence is added for the measureDate and reward fields. The editor should now look something like this.




One more edit is needed to call reviewGoals from the start template. Use an if instruction to ensure this call only happens if goal1 has been saved. The start template now looks like this.



5. Enter data and generate


Document generation requires data. Next, click on the Forms tab in the top-left area. Use the + tool under the file tree to create data files.


When you create a new data file, you need to link it to a template file which has a start template. In this example, link to member-summary.xsl. The forms screen will now display as follows.



The member and fitness-goals forms can be used to enter data - they look just like the form previews shown earlier. The order of forms and labels for these tabs can be changed in the template file using File options / Form setup....


The eye icon shows a preview of generated content. It can be useful if you only have three free generations per month in the free Community plan. The wand icon will generate the document and save to a *.docx file. The export icon combines one or more data files into a CSV file. The pencil icon opens the current report in the template editor.


The first attempt at generating a *.docx goes OK, but there are spacing issues.



6. Fine tune spacing and layout


There are a few more changes needed to get spacing right. In the future, we plan on detecting some of these issues and suggesting changes automatically. For now, you can modify margins and whether or not characters are in a block (paragraph).


Margins are set using the 4-arrow icon on the Block toolbar. Open the reviewGoals template and place the typing caret in the paragraph starting with "The next date to measure progress". Open the margins dialog and set the top margin to 10pt.


The extra space above "Micky has goals" is due to an issue of nesting blocks. Blocks are comparable to paragraphs and if you ever press the Enter key to create a new line, a new block is created with the default margin-bottom of 10pt.


The problem is, sometimes you don't want a block. For example, if a call-template instruction is in a block and it calls content that also has blocks, you can get more margin than wanted. That is the issue in this example.


The More icon (3 vertical dots) in the Block toolbar has a menu item to fix this. Put the typing caret on the line containing call:listPlans and select the Change blocks to plain text menu item in the More menu. The same adjustment is needed within the if instruction that calls reviewGoals.


One final adjustment is needed to set the top margin of the first block in reviewGoals to 10pt. Now the generated document looks like this.



The example is now complete. You can download all discussed files from the Samples app in Tag by selecting the Gym demos / Member summary sample.

4 views0 comments