Content
Displays custom XAML & Lava content on the page.
Last updated
Displays custom XAML & Lava content on the page.
Last updated
⚙️ Powered by Rock RMS
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:
Or use it to implement more complex views, such as a BibleBrowser.
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.
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:
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:
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.
Accessing the entity follows this syntax: {{ Context.EntityType.Property }}