Vital Stats Widget

The Vital Stats widget displays counts for categories you define. Each row has a count derived from a status flag or a saved search. This is a highly customizable widget. You can determine how many rows are displayed and what each row reports. Each row is configured with a name (to describe what is being counted), a status flag code or the name of a saved search, and optionally a URL that points to search results. The count will be the number of distinct people records included in the results.

The widget is supplied by TouchPoint but is not enabled by default. To turn it on, check Enabled for the Vital Stats widget on the Admin > Advanced > Homepage Widgets page.

To customize the widget for your own use, modify lines 8-12 of the Python script below, adding or deleting lines as necessary. Please note that, until you customize it, this widget is likely to fail on your database since you may not have the same status flags, saved searches, and queries used in the supplied sample code.

For each row, the first two parameters (name and status flag or saved search) are required.

  1. The first value listed will be the name that is shown in the widget.

  2. The second value is either a status flag code or a saved search name.

    • Status flag codes are entered as the flag code, such as F8. To count only the people who have all of several flags, separate the codes with commas and no spaces, such as F8,F16.

    • Anything else is treated as a saved search name, which must match the exact name of the saved search in your database.

Optionally, if you want the name and count in the widget to be links to the search results, provide a URL as the third parameter. To get the URL, run the search and copy the second half of the URL – the part that follows your church database domain name. It will begin with /Query/ and conclude with a system-generated identifier. An example is provided in line 10 of the sample Python code below.

The widget utilizes an HTML file and a Python script as shown below. (No SQL script is needed.) Since the information in this widget is the same for all users, Caching is set to all users by default.

Roles Required

As supplied by TouchPoint, this widget is visible to users with the Edit role. An Admin user can change the roles for any widget in the Roles visible field on the Admin > Advanced > Homepage Widgets page.

HTML Code

Below is the HTML code for the Vital Stats widget. As supplied by TouchPoint, the file name is WidgetVitalStatsHTML.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<div class="box">
    <div class="box-title hidden-xs" style="border:0;">
        <h5>{{WidgetName}}</h5>
    </div>
    <a class="visible-xs-block" id="{{WidgetId}}-collapse" data-toggle="collapse" href="#{{WidgetId}}-section" aria-expanded="true" aria-controls="{{WidgetId}}-section">
        <div class="box-title">
            <h5><i class="fa fa-chevron-circle-right"></i>&nbsp;&nbsp;{{WidgetName}}</h5>
        </div>
    </a>
    <div class="collapse in" id="{{WidgetId}}-section">
        {{#ifGT results.Count 0}}
            <ul class="list-group bordered">
                {{#each results}}
                    {{#ifEqual name "Total"}}
                        <li class="list-group-item"><strong>{{name}}</strong><a href="{{url}}" class="badge badge-primary" style="float:right;font-weight:bold;">{{count}}</a></li>
                    {{else}}
                        <li class="list-group-item"><a href="{{url}}">{{name}}</a><a href="{{url}}" style="float:right;">{{count}}</a></li>
                    {{/ifEqual}}
                {{/each}}
            </ul>
        {{else}}
            <div class="box-content"></div>
        {{/ifGT}}
    </div>
</div>

Python Script

Below is the Python script for the Vital Stats widget. As supplied by TouchPoint, the file name is WidgetVitalStatsPython.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import re
# You can report summary numbers for any status flag or saved search you have set up with this widget
# Example data is below, to use put the name you want to appear in the widget, followed by the status flag code or saved search name on each line
# You can also use multiple status flag codes in a line by separating them by a comma - this will show the number of people that have ALL of the specified flags
# You can link the number to any url as well with a third parameter

statusFlags = [
    ( "Community Group", "F8" ),
    ( "Leaders", "F16"),
    ( "Volunteers", "Volunteers", "/Query/f9449433-f972-46b0-95ab-ce142b5d54cb"),
    ( "New Visitors", "F31" ),
    ( "Total", "F20" ),
]

def Get():
    results = []
    template = Data.HTMLContent
    
    for item in statusFlags:
        flag = model.DynamicData()
        flag.name = item[0]
        flag.flag = item[1]
        if re.search('^F\d+(,F\d+)*$',item[1]) is None:
            flag.count = q.QueryCount(item[1])
        else:
            flag.count = q.StatusCount(item[1])
        if len(item) > 2:
            flag.url = item[2]
        else:
            flag.url = '#'
        results.append(flag)
    
    Data.results = results
    print model.RenderTemplate(template)
Get()


Latest Update

10/22/2026

Added status flag codes, the default role, and enabling the widget; updated the sample script to match the installed version.