Content

Displays custom XAML & Lava content on the page.

Arguably the most fundamental block in any Rock Mobile application, this block could be described as a necessity, used to render Lava and XAML within your shell, as provided in the "Content" block setting. If you are unfamiliar with XAML, please refer to the official Microsoft documentation. If you are unfamiliar with Lava, please check out the Rock Lava Reference.

For example, you could use it to display a simple label:

<Label Text="Hello!" />

Or use it to implement more complex views, such as a BibleBrowser.

Block Configuration

Dynamic Content This setting is extremely useful. When checked, it will download fresh content from the server every time the page is initialized. In a sense, it causes the content to "refresh" every time the page is loaded.

We recommend setting this to Yes unless there's a specific reason to leave it turned off.

If you have static, unchanging content, you can leave this as a No. This means that a Deploy will be required before the content is updated in-app. Behind the scenes, this content will be baked into the shell bundle that's downloaded during the app launch. Lava will still be processed, but you won't have a CurrentPerson context.

Using Lava

After the content, the second block setting to discuss is the "Enabled Lava Commands". If you have a Lava command within your Content, it is important to make sure to check the applicable settings here. It is also just as vital to make sure that you check the "Process Lava on Server" setting within the 'Block Properties > Mobile Settings', as seen here:

Entity Context

With just a few settings, you can wire up entity context to the Content block making it even more powerful! Maybe you want to create a profile page for people based on Search results. Instead of running Lava in the content to pull the needed data, let the block set the person context for you.

Using the Context Entity Type setting in the block, you can select any of the available entities.

Next, you'll need to set the context parameter for the page. This is how the block will know where to find the context identifier. This setting is found by editing the Page (not the block) and expanding the Advanced Settings section. Based on the entity type you chose, you should see a setting labeled {{ Entity }} Parameter Name. Add a parameter key that makes sense for your data.

It's generally recommended to pass context via GUID in Rock Mobile.

Now that you've set the block entity type and page context parameter, be sure to Save and Deploy. The final step is to simply link to your page and pass the appropriate context via the key you set. Going back to the example of the person profile page, you might end up with something like this:

<StackLayout>
    ...
    <Button Text="Profile"
        StyleClass="btn, btn-primary"
        Command="{Binding PushPage}"
        CommandParameter="3446dcac-0078-4ba4-a19a-65ce8b7fb776?Guid={{ Person.Guid }}" />
</StackLayout>

Within your Content block, you can check that the context isn't null and begin accessing the entity. If context wasn't set correctly, consider a graceful fallback to another page via Redirect.

<StackLayout>

    <!-- If context isn't set, fall back to page and display error message -->
    {% if Context == null %}
        <Rock:Redirect PageGuid="82370b8d-0fea-4454-8ad7-7e7c950e3345"
            QueryString="Message={{ 'Unable to find person' | UrlEncode }}" />
    {% endif %}
    
    <!-- Context has been set -->
    <Label Text="{{ Context.Person.NickName | Escape }}" />
    
</StackLayout>

Accessing the entity follows this syntax: {{ Context.EntityType.Property }}

Last updated

⚙️ Powered by Rock RMS