### Lava For Loop with Iteration Control Source: https://community.rockrms.com/Lava/lava/tags/for-tags Illustrates how to control the number, starting position, and direction of iterations in a Lava 'for' loop. This example limits iterations to 2, starts from the second item (offset 1), and reverses the order. ```Lava {% for campus in Campuses limit:2 offset:1 reversed %} {{ campus.Name }} {% endfor %} ``` -------------------------------- ### Lava Tag Syntax Example Source: https://community.rockrms.com/Lava/lava/tags/lava-tags Illustrates the use of the 'lava' tag, which reverses the typical Lava syntax. Keywords are implicitly code, and text to be displayed must be explicitly marked with the 'echo' command. This version achieves the same logic as the traditional example but with a different syntax. ```lava {% lava case numberOfGroups when 0 assign recommendedNumber = false echo "It's time to get into a group" when 1 assign recommendedNumber = true echo "It's great that you're in a group!" when 2 assign recommendedNumber = true echo "Wow, two groups, that's great!" when 3 assign recommendedNumber = false echo "Hey there over-achiever, it may be time to slow down!" else assign recommendedNumber = false echo "Please see a pastor, you're in way too many groups" endcase %} Recommended Number: {{ recommendedNumber }} ``` -------------------------------- ### Lava Comments Source: https://community.rockrms.com/Lava/lava/style Shows examples of single-line and multi-line comments in Lava. Comments are used to explain code and should be placed on their own lines. ```lava //‐ This is a single line comment /‐ This is a good example of a multi-line comment, that spans multiple lines when needed. ‐/ ``` -------------------------------- ### Example URL for Lava Webhook API Source: https://community.rockrms.com/Lava/lava/lava-api This example demonstrates a typical URL structure for accessing a custom API endpoint created with Lava webhooks in Rock RMS. The '/myapp/home' part of the URL is used to match a configured Lava template. ```text http://www.myserver.com/Webhooks/Lava.ashx**/myapp/home** ``` -------------------------------- ### Format Step Program Step Type in Lava Source: https://community.rockrms.com/Lava/lava/workflows Illustrates the pipe-delimited format for combining a step program GUID and a step type GUID for the 'Step Program Step Type' field type in Lava. ```lava 'StepProgramGuid|StepTypeGuid' ``` -------------------------------- ### Lava Case Statement Example Source: https://community.rockrms.com/Lava/lava/tags/case-tags Demonstrates the syntax and usage of the Lava 'case' statement for conditional logic based on string values. It handles specific string matches and a default case. ```Lava {% case Person.NickName %} {% when 'Ted' %} Hi Ted! {% when 'Alisha' or 'Bill' %} Hello Marbles! {% else %} Have we met? {% endcase %} ``` -------------------------------- ### Basic Lava Caching Example Source: https://community.rockrms.com/Lava/lava/commands/cache-commands This example demonstrates how to cache the results of a Lava query for a specified duration. It queries the database for persons with the last name 'Decker' and stores the results under the key 'decker-page-list' for one hour. Subsequent requests within the hour will retrieve data from the cache, improving performance. Be mindful of caching large data sets to avoid impacting server memory. ```lava {% cache key:'decker-page-list' duration:'3600' %} {% person where:'LastName == "Decker"' %} {% for person in personItems %} {{ person.FullName }}
{% endfor %} {% endperson %} {% endcache %} ``` -------------------------------- ### Lava Return Tag Example Source: https://community.rockrms.com/Lava/lava/tags/return-tags Demonstrates the usage of the 'return' tag to stop Lava processing when a condition is met, preventing further template rendering. This is useful for 'early out' patterns in conditional logic. ```lava {% if currentRegistrationCount >= maxRegistrationsAllowed %} Sorry, this event is full. No additional registrations are possible. **{% return %}** {% endif %} It's great to see you {{ CurrentPerson.NickName }}! Let's get you registered for this event. [[ Additional Registration Logic Here ]] ``` -------------------------------- ### Variable Naming: Numbers at Start (DotLiquid vs. Fluid) Source: https://community.rockrms.com/Lava/lava/fluid/differences Demonstrates the difference in variable assignment where variable names cannot start with a number in Fluid, unlike DotLiquid. This change was fixed in v17. ```dotliquid {% assign 1st = 22 %} {% assign 2nd = 3 %} ``` ```fluid {% assign first = 22 %} {% assign second = 3 %} ``` -------------------------------- ### Conditional Rendering in Lava Source: https://community.rockrms.com/Lava/lava/style Demonstrates how to conditionally render content in Lava based on the presence of a nickname. It uses an if-else block to display a personalized greeting or a prompt to log in. ```lava {% if Person.NickName %} Hello {{ Person.NickName }}! {% else %} Hi! Consider logging in for a more personal experience. {% endif %} ``` -------------------------------- ### AppendWatches Filter Example with ContentChannelItem Source: https://community.rockrms.com/Lava/lava/filters/other-filters This example demonstrates how to use the AppendWatches filter with a collection of ContentChannelItems. It retrieves the latest 3 items, appends watch data for the 'Media' attribute within a 30-day window, and then iterates through the results to display watch-related information. ```lava {% contentchannelitem where:'ContentChannelId == 5' sort:'StartDateTime desc' limit:'3' %} {% assign messagesWithWatches = contentchannelitemItems | AppendWatches:'Media',30 %} {% endcontentchannelitem %} ``` -------------------------------- ### Attempting to Query Campuses Attribute with Lava Source: https://community.rockrms.com/Lava/lava/workflows Illustrates an example of attempting to query an attribute that contains a comma-separated list of GUIDs (e.g., 'CampusesAttribute') using Lava. This type of attribute is not directly queryable for full entities. ```Lava {{ Workflow | Attribute:'CampusesAttribute','Id' }} ``` -------------------------------- ### Format Step Program Step Status in Lava Source: https://community.rockrms.com/Lava/lava/workflows Demonstrates the pipe-delimited format for combining a step program GUID and a step status GUID for the 'Step Program Step Status' field type in Lava. ```lava 'StepProgramGuid|StepStatusGuid' ``` -------------------------------- ### Whitespace Control in Lava Loops Source: https://community.rockrms.com/Lava/lava/style Illustrates the use of whitespace control characters (`-`) within Lava tags to strip leading and trailing whitespace from rendered output. This example applies it to a for loop. ```lava {%- for item in collection -%} {{ item.Title }} {%- endfor -%} ``` -------------------------------- ### Traditional Lava Syntax Example Source: https://community.rockrms.com/Lava/lava/tags/lava-tags Demonstrates the standard Lava syntax for conditional logic based on the number of groups an individual is in. It assigns a boolean value to 'recommendedNumber' and prints a message. This is the conventional way to write Lava code. ```lava {% case numberOfGroups %} {% when 0 %} {% assign recommendedNumber = false %} It's time to get into a group {% when 1 %} {% assign recommendedNumber = true %} It's great that you're in a group! {% when 2 %} {% assign recommendedNumber = true %} Wow, two groups, that's great! {% when 3 %} {% assign recommendedNumber = false %} Hey there over-achiever, it may be time to slow down! {% else %} {% assign recommendedNumber = false %} Please see a pastor, you're in way too many groups {% endcase %} Recommended Number: {{ recommendedNumber }} ``` -------------------------------- ### Looping and Data Assignment in Lava Source: https://community.rockrms.com/Lava/lava/style Illustrates how to iterate through a collection of campuses in Lava, assign a pastor object to a variable, and display campus details along with the pastor's name. It uses a for loop and the Attribute filter. ```lava {% for campus in Campuses %} {% assign campusPastor = campus | Attribute:'Pastor','Object' %}

{{ campus.Name }}

{{ campus.Description }}

{{ campusPastor.FirstName }} {{ campusPastor.LastName }} {% endfor %} ``` -------------------------------- ### Compare Guids using AsGuid Lava Filter Source: https://community.rockrms.com/Lava/lava/filters/other-filters The AsGuid filter converts input strings to Guid objects, enabling accurate comparison of Guids regardless of their string format. It returns an empty string if the input is not a valid Guid. The example shows comparing two Guid strings after conversion. ```lava {% assign guidString1 = '8FEDC6EE-8630-41ED-9FC5-C7157FD1EAA4' %} {% assign guidString2 = '8FEDC6EE863041ED9FC5C7157FD1EAA4' %}

Value 1: {{ guidString1 }}

Value 2: {{ guidString2 }}

{% if guidString1 != guidString2 %}

Compared as Strings, these values are different.

{% endif %} {% assign guidValue1 = '8FEDC6EE-8630-41ED-9FC5-C7157FD1EAA4' | AsGuid %} {% assign guidValue2 = '8FEDC6EE863041ED9FC5C7157FD1EAA4' | AsGuid %} {% if guidValue1 == guidValue2 %}

Compared as Guids, these values are the same.

{% endif %} ``` -------------------------------- ### Basic Loop Structure in Lava Source: https://community.rockrms.com/Lava/lava/style A fundamental Lava code snippet demonstrating a for loop to iterate over a collection and display the 'Title' attribute of each item. It includes standard tag formatting with spaces. ```lava {% for item in collection %} {{ item.Title }} {% endfor %} ``` -------------------------------- ### Alternate Lava For Loop for Index-Based Iteration Source: https://community.rockrms.com/Lava/lava/tags/for-tags Presents an alternative method for iterating through arrays in Lava, useful as a replacement for while loops. This example iterates from 0 up to the size of the 'Campuses' array minus one, accessing elements by index. ```Lava {% assign campusCount = Campuses | Size | Minus:1 %} {% for i in (0..campusCount) %} {{ i | Plus:1 }}. {{ Campuses[i].Name }} {% endfor %} ``` -------------------------------- ### Reference Global JavaScript Objects with Javascript Command Source: https://community.rockrms.com/Lava/lava/commands/javascript-commands This example demonstrates the 'references' parameter, which allows passing globally scoped JavaScript objects into the self-executing anonymous function. This enables your script to interact with existing JavaScript on the page. ```lava {% javascript references: 'jQuery, myGlobalObject' %} // Script can now use jQuery and myGlobalObject {% endjavascript %} ``` -------------------------------- ### Launch New Workflow by Workflow Type GUID Source: https://community.rockrms.com/Lava/lava/commands/workflow-activate-commands Activates a new workflow using its Globally Unique Identifier (GUID). This method is an alternative to using the numerical ID for specifying the workflow type. ```lava {% workflowactivate workflowtype:'8fedc6ee-8630-41ed-9fc5-c7157fd1eaa4' %} Activated new workflow with the id of #{{ Workflow.Id }}. {% endworkflowactivate %} ``` -------------------------------- ### Date Formatting with Lava Filter Source: https://community.rockrms.com/Lava/lava/style Demonstrates the correct usage of the 'Date' filter in Lava with a specific format string ('M/d/yyyy'). It shows the proper spacing around the filter and its parameter, using single quotes for the parameter. ```lava {{ 'Now' | Date:'M/d/yyyy' }} ``` -------------------------------- ### Add External Script by URL with Javascript Command Source: https://community.rockrms.com/Lava/lava/commands/javascript-commands This example uses the 'url' parameter to include an external JavaScript file. When paired with the 'id' parameter, it ensures the script is loaded only once per page, preventing redundant requests. ```lava {% javascript url: 'https://example.com/scripts/external.js', id: 'externalScript' %} ``` -------------------------------- ### Lava For Loop for Date Range Iteration Source: https://community.rockrms.com/Lava/lava/tags/for-tags Shows how to use a Lava 'for' loop to iterate over a range of years. It calculates the current year and a start year (two years prior) and then loops through each year in that range. ```Lava {% assign currentYear = 'Now' | Date:'yyyy' %} {% assign startYear = currentYear | Minus: 2 %} {% for year in (startYear..currentYear) %} {{ year }} {% endfor %} ``` -------------------------------- ### Variable Assignment in Lava Source: https://community.rockrms.com/Lava/lava/style Shows how to assign a variable in Lava using the 'assign' tag. It demonstrates assigning the first item from a 'Campuses' collection to a variable named 'campus' and then to 'firstCampus', following camel case convention. ```lava {% assign campus = Campuses | First %} {% assign firstCampus = Campuses | First %} ``` -------------------------------- ### ZebraPhoto Filter Usage Example Source: https://community.rockrms.com/Lava/lava/filters/person-filters Demonstrates how to use the ZebraPhoto Lava filter within a ZPL string to embed a person's photo. It shows the basic syntax and the expected output structure. ```Lava ^FD{{ Person | ZebraPhoto:'397',1.0,1.0,'LOGO',90 }}^FS ``` -------------------------------- ### Get All Keys from Dictionary with AllKeysFromDictionary Source: https://community.rockrms.com/Lava/lava/filters/array-filters Retrieves all keys from a dictionary object and returns them as an array. This is useful for iterating over the keys of a dictionary. ```Lava {% assign keys = Object | AllKeysFromDictionary %} ``` -------------------------------- ### Filter Persons by Expression (Aggregate) in Lava Source: https://community.rockrms.com/Lava/lava/commands/entity-commands Demonstrates using the 'expression' parameter with an aggregate function to filter entities. This example filters persons based on the count of their phone numbers. ```lava {% person expression:'PhoneNumbers.Count() > 1' %} {% for person in personItems %} {{ person.FullName }}
{% endfor %} {% endperson %} ``` -------------------------------- ### Get Person Object by Person Guid (Lava) Source: https://community.rockrms.com/Lava/lava/filters/person-filters Retrieves a full person object using the Guid of the person. This is a direct way to fetch person details if the person's unique Guid is available. ```Lava {% assign groupMemberPerson = GroupMember.Person.Guid | PersonByGuid %} Hello {{ groupMemberPerson.NickName }}! ``` -------------------------------- ### Get Media Element URL using Lava Source: https://community.rockrms.com/Lava/lava/workflows Demonstrates how to retrieve the URL of a selected media item using the Lava templating language. This is useful for dynamically displaying media content within Rock RMS pages. ```lava {{ ... | Attribute:'', 'Url' }} ``` -------------------------------- ### Client: Get Browser Information Source: https://community.rockrms.com/Lava/lava/filters/other-filters Retrieves information about the client browser, such as IP address, login details, and browser type. The 'browser' parameter returns a structured object with detailed information. ```Lava IP Address: {{ 'Global' | Client:'ip' }}
Login: {{ 'Global' | Client:'login' }}
Browser: {{ 'Global' | Client:'browser' }}
``` ```JSON { "String": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36", "OS": { "Family": "Windows 10", "Major": null, "Minor": null, "Patch": null, "PatchMinor": null }, "Device": { "IsSpider": false, "Brand": "", "Family": "Other", "Model": "" }, "UserAgent": { "Family": "Chrome", "Major": "57", "Minor": "0", "Patch": "2987" }, "UA": { "Family": "Chrome", "Major": "57", "Minor": "0", "Patch": "2987" } } ``` ```Lava {{ 'Global' | Client:'parmlist' }} ``` -------------------------------- ### Get Person Object by Alias Guid (Lava) Source: https://community.rockrms.com/Lava/lava/filters/person-filters Retrieves a full person object using the Guid of a person alias. This is useful when you have the alias Guid and need to access the associated person's details. ```Lava {% assign campusLeader = Campus.LeaderPersonAliasGuid | PersonByAliasGuid %} Hello {{ campusLeader.NickName }}! ``` -------------------------------- ### Combine AND and OR in Where Clause Source: https://community.rockrms.com/Lava/lava/commands/entity-commands Explains the required order for combining `&&` (AND) and `||` (OR) operators in Rock RMS 'where' clauses. The `&&` condition must always be listed last. This example filters group members by multiple GroupIds and a specific PersonId. ```lava {% groupmember where:'GroupId == 3 || GroupId == 33 || GroupId == 2 && PersonId == {{ Person.Id }}' %} ``` -------------------------------- ### Import Less Variables into Stylesheet Source: https://community.rockrms.com/Lava/lava/commands/stylesheet-commands This example demonstrates using the 'import' parameter to include Less files, such as variable definitions, into the stylesheet. It allows leveraging theme-defined variables for consistent styling. The snippet also shows how to define custom variables. ```lava {% stylesheet compile:'less' import:'_variables.less,_css-overrides.less' %} @theme-1: green; #content-wrapper { background-color: @theme-1 !important; color: #fff; } {% endstylesheet %} ``` -------------------------------- ### Get Date Range from Sliding Format with DateRangeFromSlidingFormat Source: https://community.rockrms.com/Lava/lava/filters/date-filters Parses a sliding date range format string to extract a start and end date. This is typically used with the Sliding Date Range control. The output includes the formatted start and end dates. ```Lava {% assign range = 'Previous|2|Week||' | DateRangeFromSlidingFormat %} {{ range.StartDate }} - {{ range.EndDate }} ``` -------------------------------- ### Search with Different Search Types in Lava Source: https://community.rockrms.com/Lava/lava/commands/search-commands Explains how to use the `search` command with the `searchtype` parameter to control the matching logic (e.g., 'wildcard'). While 'exactmatch' is recommended, other types offer different matching behaviors for flexibility. ```lava {% search query:'ted decker' searchtype:'wildcard' %} {% for result in results %} {{ result.DocumentName }} {% endfor %} {% endsearch %} ``` -------------------------------- ### Calculate and Format Time Difference Between Dates Source: https://community.rockrms.com/Lava/lava/filters This example shows how to use the 'HumanizeTimeSpan' filter to calculate the difference between two dates and display it in a human-readable format. It takes a start date, an end date, and an optional precision level as input. ```lava {{ '1/1/2014' | HumanizeTimeSpan:'1/14/2014',2 }} ``` -------------------------------- ### Get Personalization Items for a Person (Lava) Source: https://community.rockrms.com/Lava/lava/filters/person-filters Retrieves personalization items (segments and/or request filters) for a given person and current page context. The input can be a Person object, Guid, or Id. An optional comma-delimited list of item types can be provided. ```Lava {% assign items = CurrentVisitor | PersonalizationItems:'Segments,RequestFilters' %} {% for item in items %} {{ item.Type }} - {{ item.Key }} {% endfor %} ``` -------------------------------- ### Basic Search Query in Lava Source: https://community.rockrms.com/Lava/lava/commands/search-commands Demonstrates a basic search query using the `search` command in Rock RMS Lava. It takes a query term and iterates through the results to display document names. No external dependencies are required beyond the Lava templating engine. ```lava {% search query:'ted decker' %} {% for result in results %} {{ result.DocumentName }} {% endfor %} {% endsearch %} ``` -------------------------------- ### Querying Person Attributes with Lava Source: https://community.rockrms.com/Lava/lava/workflows Demonstrates how to query for properties and attributes of a 'Person' entity using Lava. It highlights that attributes representing full entities, like 'FirstName', are queryable, while others are not. ```Lava {{ Workflow | Attribute:'PersonAttribute','FirstName' }} ``` -------------------------------- ### FromIdHash: Get Rock Entity Id from IdHash string (Lava) Source: https://community.rockrms.com/Lava/lava/filters/other-filters The FromIdHash filter returns a Rock Entity Id from an IdHash string generated by the ToIdHash filter. If the IdHash cannot be converted to a valid integer Id, it returns an empty value. Starting in v17.3, if the input is a non-hashed integer string, that integer value is immediately returned. ```Lava //- Get the IdHash for Ted Decker. {% person where:'LastName == "Decker" && NickName =="Ted"' %} ... {% assign idHash = person.IdKey %} ... {% endperson %} Ted's IdHash is: {{ idHash }}.
//- Pass the IdHash to the FromIdHash filter to get the person's Id. {% assign personFromHash = idHash | FromIdHash | PersonById %} Hello {{ personFromHash.NickName }}! ``` -------------------------------- ### Set Date Range for Calendar Events Source: https://community.rockrms.com/Lava/lava/commands/calendar-events This example shows how to specify a date range for filtering calendar events using the 'daterange' parameter within the 'calendarevents' Lava command. The format 'Xd' allows filtering by days, weeks, or months from the start date. This is useful for retrieving events within a specific future period. ```Lava daterange:'4w' ``` -------------------------------- ### Retrieve Group by GUID using GroupByGuid Filter Source: https://community.rockrms.com/Lava/lava/filters/other-filters The GroupByGuid filter retrieves a full Group object using its unique GUID. It takes the group's GUID as input and returns the corresponding group details. This is useful for accessing group information when only the GUID is known. ```Lava {% assign group = GroupMember.Group.Guid | GroupByGuid %} Group Name: {{ group.Name }}! ``` -------------------------------- ### Format Page Reference in Lava Source: https://community.rockrms.com/Lava/lava/workflows Details the format for 'Page Reference' field type in Lava, which can include both Page GUID and PageRoute GUID, though only the Page GUID is mandatory. ```lava 'Page.Guid,PageRoute.Guid' ``` -------------------------------- ### Eager Loading Models in Lava Commands Source: https://community.rockrms.com/Lava/lava/commands/entity-commands The 'include' parameter allows for eager loading of specified related models. This fetches associated data upfront, potentially reducing the number of subsequent queries needed to access related properties. ```Lava {% person where:'LastName == "Decker"' include:'ConnectionStatusValue' %} {% for person in personItems %} {{ person.NickName }} - {{ person.ConnectionStatusValue.Value }}
{% endfor %} {% endperson %} ``` -------------------------------- ### Represent Entity with Lava Source: https://community.rockrms.com/Lava/lava/workflows Explains how to represent an entity using its GUID and ID. The format is a pipe-delimited string: 'GUID|Integer', where GUID is the entity type's GUID and Integer is the specific entity's ID. This is commonly used for referencing specific records. ```lava {{ 'EntityTypeGUID' | Entity:'EntityId' }} ``` -------------------------------- ### Observe Lava Command for Performance Benchmarking Source: https://community.rockrms.com/Lava/lava/tags/observe The `observe` Lava command wraps contained Lava code into an observability activity, providing detailed performance timings and grouping database calls. The `name` parameter is required, and additional parameters function as tags for the activity. Tag values should be escaped if they contain special characters. ```lava {% observe name:'Family List' rsc-feature:'family-list' rsc-feature-version:'2' %} {% person where:'LastName == "Decker"' %} {% for person in personItems %} {{ person.FullName }} {% endfor %} {% endperson %} {% endobserve %} ``` -------------------------------- ### Format Person Address using Lava Source: https://community.rockrms.com/Lava/lava/filters/person-filters The Address filter formats a person's address. It accepts an address type (e.g., 'Home', 'Work') and an optional format template. In Rock v3.0 and later, the template allows for custom address formatting using merge fields like [[City]] and [[State]]. Starting with Rock 4.0, 'Mailing' and 'MapLocation' address types are available. Rock v7.0 allows passing a PersonId, and v13.0 provides the Location Guid. ```lava Home Address: {{ CurrentPerson | Address:'Home' }} {{ CurrentPerson | Address:'Home','[[City]], [[State]]' }} ``` -------------------------------- ### Convert Entity GUIDs to IDs using GuidToId Filter Source: https://community.rockrms.com/Lava/lava/filters/other-filters The GuidToId filter converts one or more entity GUID identifiers to their corresponding Id values for a specified entity type. It accepts a single Guid, a comma-delimited list, or an array, returning an array of IDs in the same order. The EntityType parameter is required. ```Lava {% assign personGuid = '8fedc6ee-8630-41ed-9fc5-c7157fd1eaa4' %} {% assign personEntityTypeId = '72657ed8-d16e-492e-ac12-144c5e7567e7' | GuidToId:'EntityType' %} {% assign personId = personGuid | GuidToId:personEntityTypeId %} Ted Decker's record can be identified by Guid '{{ personGuid }}' or Id '{{ personId }}'. ``` -------------------------------- ### Null Comparison in Fluid vs. DotLiquid Source: https://community.rockrms.com/Lava/lava/fluid/differences Demonstrates the difference in how null values are compared using the '<=' operator in Fluid and DotLiquid. This can lead to unexpected results if variables assigned from attributes or content items become null. ```lava {% assign var1 = null %} {% assign var2 = null %} {% if var1 <= var2 %} inside the IF {% else %} inside the ELSE {% endif %} ``` -------------------------------- ### Format Metric Categories in Lava Source: https://community.rockrms.com/Lava/lava/workflows Shows the comma-delimited list format for 'Metric Categories' in Lava, where each item is a pipe-delimited pair of metric GUID and category GUID. ```lava 'MetricGUID1|CategoryGUID1,MetricGUID2|CategoryGUID2' ``` -------------------------------- ### POST /api/Lava/RenderTemplate Source: https://community.rockrms.com/Lava/lava/remote-lava The Lava REST endpoint is a simple endpoint that takes Lava as input and returns the rendered template as output. This endpoint is easily used by any programming language, including JavaScript. Be very careful when using this endpoint if Javascript as your source code is visible to all users. Seeing the endpoint and the API key allows them to send any Lava they'd like, which would be run by the user linked to the API key. This is fine if you've carefully locked down the endpoint, but generally you should avoid using Javascript and instead use PHP, Ruby, or some other server-side language. To enforce security this endpoint can only be accessed by HTTPS. ```APIDOC ## POST /api/Lava/RenderTemplate ### Description Renders a Lava template provided as input and returns the rendered output. ### Method POST ### Endpoint `http://rock.rocksolidchurchdemo.com/api/Lava/RenderTemplate` ### Parameters #### Query Parameters None #### Request Body - **lavaTemplate** (string) - Required - The Lava template string to be rendered. ### Headers - **Authorization-Token** (string) - Required - The API key for authentication. - **Content-Type** (string) - Required - `application/x-www-form-urlencoded; charset=UTF-8` - **Content-Length** (integer) - Required - The length of the request body. ### Request Example (PHP) ```php ``` ### Request Example (JavaScript) ```javascript
``` ### Response #### Success Response (200) - **renderedTemplate** (string) - The rendered Lava template output. #### Response Example ```json "John Doe" ``` #### Error Handling - **400 Bad Request**: If the request body is invalid or missing. - **401 Unauthorized**: If the API key is invalid or missing. - **500 Internal Server Error**: If there is a server-side issue. ``` -------------------------------- ### Basic If-Elsif-Else Structure in Lava Source: https://community.rockrms.com/Lava/lava/tags/if-else-tags Demonstrates the fundamental usage of the 'if', 'elsif', and 'else' tags for conditional logic in Lava. This structure allows for multiple conditions to be checked sequentially. ```Lava {% if Person.NickName == 'Ted' %} Great Guy! {% elsif Person.NickName == 'Alisha' %} Great Gal! {% else %} Who are you? {% endif %} ``` -------------------------------- ### Dynamically Apply Stylesheet Based on Time of Day Source: https://community.rockrms.com/Lava/lava/commands/stylesheet-commands This example shows how to combine the stylesheet command with other Lava commands and filters to create dynamic styling. It uses the Date filter and an if condition to change the background color based on the current hour, demonstrating conditional styling. ```lava {% assign hour = 'Now' | Date:'H' %} {% stylesheet %} #page-content { {% if hour == 12 %} background-color: PeachPuff !important; {% else %} background-color: SkyBlue !important; {% endif %} color: #fff; } {% endstylesheet %} ``` -------------------------------- ### Lava Cache with Local Variable Scope Example Source: https://community.rockrms.com/Lava/lava/commands/cache-commands This example illustrates how local variables assigned within a cache tag are scoped only to that tag. The variable 'color' is initially 'blue'. Inside the cache block, it's changed to 'red', but this change is not reflected outside the cache block. This highlights that updates to local variables within a cache tag do not persist after the cache is processed. ```lava {% assign color = 'blue' %} Color 1: {{ color }} {% cache key:'fav-color' duration:'1200' %} Color 2: {{ color }} {% assign color = 'red' %} Color 3: {{color }} {% endcache %} Color 4: {{ color }} ``` -------------------------------- ### Web Request with Parameters (Lava) Source: https://community.rockrms.com/Lava/lava/commands/web-request-commands Shows how to pass parameters to a web request to filter results, using the GitHub API as an example. It demonstrates filtering by author and limiting the number of results returned. Parameters are formatted as 'key^value' pairs delimited by '|'. ```Lava {% webrequest url:'https://api.github.com/repos/SparkDevNetwork/Rock/commits' parameters:'per_page^1|author^edmistj' %} {% endwebrequest %} ``` -------------------------------- ### Get Array Size (Lava) Source: https://community.rockrms.com/Lava/lava/filters/array-filters Provides the number of items in an array. It takes an array as input and returns an integer representing the count of elements in that array. ```Lava Ted has {{ Person.PhoneNumbers | Size }} phone numbers. ``` -------------------------------- ### Basic Cycle Tag Usage in Lava Source: https://community.rockrms.com/Lava/lava/tags/cycle-tags Demonstrates the fundamental use of the Lava cycle tag to alternate through a list of strings. This is useful for applying sequential styles or values within loops. ```Lava {% cycle 'red', 'green', 'blue' %} {% cycle 'red', 'green', 'blue' %} {% cycle 'red', 'green', 'blue' %} ``` -------------------------------- ### Basic Lava For Loop Source: https://community.rockrms.com/Lava/lava/tags/for-tags Demonstrates the fundamental usage of the 'for' tag to iterate over an array of objects in Lava. It iterates through a collection named 'Campuses' and outputs the 'Name' property of each item. ```Lava {% for campus in Campuses %} {{ campus.Name }} {% endfor %} ``` -------------------------------- ### Get Parents with Lava Source: https://community.rockrms.com/Lava/lava/filters/person-filters The Parents filter retrieves a list of adults in a specified person's family. It can accept a full person model or a PersonId as input. ```lava {% assign parents = CurrentPerson | Parents %} My parents are: {% for person in parents %}
  • {{ person.FullName }}
  • {% endfor %} ``` -------------------------------- ### ZebraPhoto Filter with Check-in Label Integration Source: https://community.rockrms.com/Lava/lava/filters/person-filters Shows how to integrate the ZebraPhoto filter into a check-in label setup. This involves adding a field to the ZPL and a corresponding Label Merge Field in Rock, along with specifying the image placement using ^FO and ^XG commands. ```ZPL ^FDPhoto^FS ^FO25,68^XGR:LOGO.PNG,1,1^FS ``` -------------------------------- ### Get Person by Alternate Id (Lava) Source: https://community.rockrms.com/Lava/lava/filters/person-filters Retrieves a person object from a provided alternate identifier. This filter is useful for looking up individuals using a secondary unique ID. ```Lava {% assign person = PersonAlternateId | PersonByPersonAlternateId %} Hello {{ person.FullName }}! ``` -------------------------------- ### Include Statement Syntax: Commas vs. Colons (DotLiquid vs. Fluid) Source: https://community.rockrms.com/Lava/lava/fluid/differences Illustrates the change in syntax for passing variables to an 'include' tag. DotLiquid uses a colon, while Fluid requires commas to separate variable assignments. ```dotliquid {% assign fruit = 'apples' %} {% include 'template' myVariable:fruit otherVariable:'oranges' %} ``` ```fluid {% assign fruit = 'apples' %} {% include 'template', myVariable:fruit, otherVariable:'oranges' %} ``` -------------------------------- ### Get Distinct Elements from Array with Distinct Source: https://community.rockrms.com/Lava/lava/filters/array-filters Returns an array containing only the unique elements from the input array. It can also accept a property name to determine uniqueness for complex objects. ```Lava {% assign array = Items | Distinct:'Person.Id' %} ``` -------------------------------- ### Search with AND Field Criteria in Lava Source: https://community.rockrms.com/Lava/lava/commands/search-commands Demonstrates how to perform searches using the `search` command with `criteriasearchtype:'and'` to combine multiple `fieldcriteria` with AND logic. This provides more restrictive search capabilities compared to the default OR logic. ```lava {% search query:'ted decker' entities:'group' fieldcriteria:'GroupTypeName^Serving Team|Name^Usher*' criteriasearchtype:'and' %} {% for result in results %} {{ result.DocumentName }} {% endfor %} {% endsearch %} ``` -------------------------------- ### Get Person Object by Person Id (Lava) Source: https://community.rockrms.com/Lava/lava/filters/person-filters Retrieves a full person object using the Id of the person. This filter is used when the person's unique Id is known. ```Lava {% assign groupMemberPerson = GroupMember.PersonId | PersonById %} Hello {{ groupMemberPerson.NickName }}! ``` -------------------------------- ### Execute SQL Query and Iterate Results (Lava) Source: https://community.rockrms.com/Lava/lava/commands/sql-commands This snippet demonstrates how to execute a basic SQL SELECT query using the `{% sql %}` command and then iterate over the returned `results` in Lava. It fetches NickName and LastName for individuals named 'Decker'. ```Lava {% sql %} SELECT [NickName], [LastName] FROM [Person] WHERE [LastName] = 'Decker' {% endsql %} {% for item in results %} {{ item.NickName }} {{ item.LastName }}
    {% endfor %} ``` -------------------------------- ### Lava 'where' Parameter Operators Source: https://community.rockrms.com/Lava/lava/commands/entity-commands This is not executable code but a reference for operators used within the Lava 'where' parameter for filtering entities. It lists common comparison and logical operators available for building complex queries. ```markdown ==| Equal !=| Not equal ^=| Starts with *=| Contains *!| Does not contain _=| Is blank _!| Is not blank >| Greater than >=| Greater than or equal <| Less than <=| Less than or equal $=| Ends with &&| Conditional logical AND operator ||| Conditional logical OR operator ``` -------------------------------- ### Lava Templating: Unless Statement Example Source: https://community.rockrms.com/Lava/lava/tags/unless-tags Demonstrates the usage of the 'unless' statement in Lava templating. This statement executes its block if the condition evaluates to false. It is the logical inverse of the 'if' statement. ```lava {% unless Person.NickName == '' %} Hi {{ Person.NickName }} {% endunless %} ``` -------------------------------- ### Set Related Entity ID for Interaction Logging Source: https://community.rockrms.com/Lava/lava/commands/interaction-write Specifies the exact entity a related entity is referring to, used with 'relatedentitytypeid'. Example shows setting 'relatedentityid' to '1'. ```lava relatedentityid:'1' ``` -------------------------------- ### Debugging Lava Data with Debug Filter Source: https://community.rockrms.com/Lava/index This Lava example shows how to use the 'Debug' filter to display available data within the Lava environment. It's a useful tool for understanding what data can be accessed and used in templates. The output of this filter helps in debugging and exploring data sources. ```lava {{ 'Lava' | Debug }} ``` -------------------------------- ### Represent Group Type Group with Lava Source: https://community.rockrms.com/Lava/lava/workflows Shows how to represent a group within a group type. The format is two pipe-delimited GUIDs: GroupTypeGUID|GroupGUID. This is useful for referencing specific groups that belong to a particular type. ```lava {{ 'GroupTypeGUID' | GroupTypeGroup:'GroupGUID' }} ``` -------------------------------- ### Use SQL Aggregate Functions with Aliases (Lava) Source: https://community.rockrms.com/Lava/lava/commands/sql-commands This snippet shows how to use SQL aggregate functions, such as `MIN()`, within the `{% sql %}` command. It emphasizes the necessity of assigning an alias (e.g., 'Date') to the aggregated field for it to be accessible in Lava. ```Lava {% sql %} SELECT MIN(gm.[CreatedDateTime]) AS 'Date' FROM [GroupMember] AS gm INNER JOIN [Group] AS g ON g.[Id] = gm.[GroupId] INNER JOIN [Person] AS p ON p.[Id] = gm.[PersonId] WHERE g.[GroupTypeId] IN (1, 2, 3) {% endsql %} {% for item in results %} {{ item.Date }} {% endfor %} ``` -------------------------------- ### HTML Link with Class Attribute Source: https://community.rockrms.com/Lava/lava/style A standard HTML snippet demonstrating an anchor tag (``) with a class attribute ('btn') and an href attribute. It follows the rule of using double quotation marks for attribute values. ```html Sign in ``` -------------------------------- ### Execute SQL with Lava Variables (Lava) Source: https://community.rockrms.com/Lava/lava/commands/sql-commands This example shows how to embed Lava variables within a SQL query. It assigns a last name to a Lava variable and then uses it in the `WHERE` clause. It highlights the importance of preventing SQL injection when using dynamic values. ```Lava {% assign lastName = 'Decker' %} {% sql %} SELECT [NickName], [LastName] FROM [Person] WHERE [LastName] = '{{ lastName }}' {% endsql %} {% for item in results %} {{ item.NickName }} {{ item.LastName }}
    {% endfor %} ``` -------------------------------- ### Include Lava Template File Source: https://community.rockrms.com/Lava/lava/tags/include-tags The 'include' tag reads the content of a specified file and processes its Lava syntax as a template. This is useful for reusing common template structures like navigation menus. The tag supports placeholders like '~~' for the current theme's directory and '~' for the application root. ```lava {% include '~~/Assets/Lava/PageNav.lava' %} ``` -------------------------------- ### Slice: Substring Extraction Source: https://community.rockrms.com/Lava/lava/filters/text-filters Extracts a substring from a given string, starting at a specified index. An optional second parameter can define the length of the substring. If the length is omitted, a single character is returned. ```Lava First two characters '{{ Person.SecurityCode | Slice: 0, 2 }}' and the last three characters '{{ Person.SecurityCode | Slice: 2, 3 }}'. ``` -------------------------------- ### Slice Array Subset with Lava Source: https://community.rockrms.com/Lava/lava/filters/array-filters The Slice filter extracts a subset of an array. It takes a starting index and an optional length. If the length is omitted, it defaults to one element. This filter is compatible with the Fluid engine. ```lava {% assign sublist = List | Slice:2,3 %} ``` -------------------------------- ### ZebraPhoto Filter ZPL Output Example Source: https://community.rockrms.com/Lava/lava/filters/person-filters Illustrates the ZPL code generated by the ZebraPhoto filter when embedding image data. This includes the ~DYR command for image transfer and field data commands. ```ZPL ^FD^FS~DYR:LOGO,P,P,12246,,89504E470A50C317A8C32490DF5A6...90A9CD5B34A9B0FA2A842E095F5CE082^FD^FS ``` -------------------------------- ### Boolean and Null Comparisons in Lava Source: https://community.rockrms.com/Lava/lava/tags/if-else-tags Illustrates how to correctly compare boolean attributes in Lava using the 'AsBoolean' filter, including checks for 'true', 'false', and 'null' values. This ensures robust handling of attribute states. ```Lava {% assign isTrained = CurrentPerson | Attribute:'IsTrained' | AsBoolean %} isTrained is : "{{ isTrained }}"
    {% if isTrained == true %} Evaluates to true {% elsif isTrained == false %} Evaluates to false {% elsif isTrained == null %} Evaluates to null -- meaning there is no value stored {% else %} Evaluates to something else? {% endif %} -- renders -- isTrained is : "" Evaluates to null -- meaning there is no value stored ``` -------------------------------- ### Dynamic Parameters in Lava Commands Source: https://community.rockrms.com/Lava/lava/commands/entity-commands Allows Lava commands to use values from the query string as parameters. This enables dynamic filtering and data retrieval based on URL parameters. It can accept single parameters or a comma-separated list for filtering. ```Lava {% person dynamicparameters:'Id' %} {% for person in personItems %} {{ person.FullName }}
    {% endfor %} {% endperson %} ``` ```Lava {% assign groupid = PageParameter['groupId'] %} {% groupmember where:'GroupId == {{groupid}}' %} {% for gm in groupmemberItems %} {{ gm.Person.FullName }}
    {% endfor %} {% endgroupmember %} ``` ```Lava {% person dynamicparameters:'LastName,NickName' %} {% for person in personItems %} {{ person.FullName }}
    {% endfor %} {% endperson %} ``` -------------------------------- ### Convert Text to Lowercase using Lava Source: https://community.rockrms.com/Lava/lava/filters/text-filters Transforms all characters in a string to lowercase. For example, 'LoRem IpSum DoLor' becomes 'lorem ipsum dolor'. This filter is available from Server v1.0. ```lava

    {{ Person.FullName | Downcase }}

    ``` -------------------------------- ### GroupBy Key and Entity Array in Rock RMS Lava Source: https://community.rockrms.com/Lava/lava/commands/entity-commands Groups rows with the same values into summary rows. This example demonstrates a simple groupby operation, returning the key and an array of the grouped entities. The keyword 'it' refers to the current grouped entity. ```Lava {% person groupby:'LastName' where:'Gender == 1' select:'new (Key as Key, it AS People)' %} {% for row in personItems %} {{ row.Key }}
    {% for person in row.People %} {{ person.LastName }}, {{ person.NickName }}
    {% endfor %} {% endfor %} {% endperson %} ``` -------------------------------- ### Select Aggregate Functions in Rock RMS Lava Source: https://community.rockrms.com/Lava/lava/commands/entity-commands Shows how to use the 'select' command to perform aggregate functions like 'Count()' on related entities. This allows for summarizing data within groups, such as counting members in a group. ```Lava {% group where:'GroupTypeId == 25' select:'new ( Id AS GroupId, Name AS GroupName, Members.Count() AS GroupMemberCount )' %}
    {{ groupItems | First | ToJSON }}
    
    {% endgroup %} ``` -------------------------------- ### Launch New Workflow (Basic) Source: https://community.rockrms.com/Lava/lava/commands/workflow-activate-commands Launches a new workflow of a specified type. It demonstrates the basic syntax and how to access the new workflow's ID using the 'Workflow.Id' variable within the command block. Requires knowing the workflow type ID. ```lava {% workflowactivate workflowtype:'21' %} Activated new workflow with the id of #{{ Workflow.Id }}. {% endworkflowactivate %} ```