Skip to content

Lava Templating for Staff Page ​

Overview ​

The staff page utilizes Lava templating for dynamic rendering of staff and pastor information. This templating system integrates data from Rock RMS and organizes it into a responsive, sortable layout with interactive UI elements.

Data Structure ​

  • Dynamic Staff Data: Staff and pastors are fetched and displayed based on attributes such as Group, Priority, Title, and Position.

  • Static Data: Certain sections, like the Administration group, are hardcoded for consistency.

  • Sorting: Staff members are sorted by their Priority or Title for logical display.

K### ey Templating Code Breakdown

  1. Pastor Listing (Dynamic)
  • Sorted pastors are displayed dynamically based on their group membership (Pastor).

  • Lava Logic:

LAVA
{% assign sortedPastors = Items | Sort:'Priority' %}
{% for person in sortedPastors %}
    {% assign groups = person | Attribute:'Group' | Split: ',' %}
    {% assign is_pastor = false %}
    {% for group in groups %}
        {% if group == 'Pastor' %}
            {% assign is_pastor = true %}
        {% endif %}
    {% endfor %}
    {% if is_pastor %}
        <div class="twmc-pastors">
            <a href="{{ person | Attribute:'Link' }}">
                <img src="{{ person | Attribute:'Image' }}" alt="{{ person.Title }}">
            </a>
            <p>{{ person.Title }}</p>
            <p>{{ person | Attribute:'Position' }}</p>
        </div>
    {% endif %}
{% endfor %}
  • Description: This loop checks if each person belongs to the "Pastor" group, then displays their photo, title, and position.
  1. Accordion for Groups (Dynamic)
  • Each staff group (e.g., Adults 55, Creative Services) is rendered within an accordion.

  • Lava Logic:

Lava
{% assign groups = 'Adults 55,Creative Services,Children' | Split: ',' %}
{% for group in groups %}
    <div class="panel">
        <h4>{{ group }}</h4>
        <div>
            {% assign sortedStaff = Items | SortBy:'Title' %}
            {% for staff_member in sortedStaff %}
                {% if staff_member | Attribute:'Group' contains group %}
                    <p>{{ staff_member.Title }}</p>
                    <p>{{ staff_member | Attribute:'Position' }}</p>
                    <a href="mailto:{{ staff_member | Attribute:'Email' }}">Email</a>
                {% endif %}
            {% endfor %}
        </div>
    </div>
{% endfor %}
  • Description: Loops through groups, fetching relevant staff members, and displays them in a collapsible panel with contact information.
  1. Staff Details
  • Displays detailed staff information, including name, position, email, and phone.

  • Lava Logic:

lava
<div>
    <p><strong>{{ staff_member.Title }}</strong></p>
    <p>{{ staff_member | Attribute:'Position' }}</p>
    <p>Email: <a href="mailto:{{ staff_member | Attribute:'Email' }}">{{ staff_member | Attribute:'Email' }}</a></p>
    <p>Phone: {{ staff_member | Attribute:'Phone' }}</p>
</div>
  • Description: This template section displays the detailed information of a single staff member.

Anti-Fragile Design Considerations ​

  • Data Integrity: Ensures staff and pastor data is sorted and displayed in a structured manner, making the system more resilient to changes in the underlying data.

  • Error Handling: Missing or incorrect attributes are handled gracefully with default fallback values (e.g.,   for missing captions).

  • Dynamic Rendering: Group names and staff information are processed dynamically to accommodate future changes in group names or staff structure.

Usage ​

  • For Pastors: A loop filters the staff list to only show pastors, sorting them based on priority.

  • For Groups: An accordion section dynamically renders staff based on the group they belong to.

Explore and learn. Released under the MIT License.