Live Updates Example - Enforcing Filters
Introduction and Use Cases
Example
Liquid in the wrapper.liquid file
{% comment %} Get public key as normal {% endcomment %}
{% function public_key = "modules/module_86/front_end/functions/v1/live_update_params_encode", layout: layout, model: _model, collection: 'false', creator_id: nil %}
{% comment %} Generate unique ID for the layout, unless one has already been generated and sent in the params. The main purpose of doing this here is to help the JavaScript reliably reference the instance of the Live Update object created for this layout.{% endcomment %}
{% if params.sitebuilder_uniq_component_id %}
{% assign sitebuilder_uniq_component_id = params.sitebuilder_uniq_component_id %}
{% else %}
{% capture sitebuilder_uniq_component_id %}sitegurus_component_{% increment sitegurus_gen_uniq_component_id %}{% endcapture %}
{% endif %}
{% comment %} Output Layout Wrapper code. {% endcomment %}
<section data-sg-live-update-key="{{public_key}}" id="{{sitebuilder_uniq_component_id}}_table" data-sg-live-update-section="{{sitebuilder_uniq_component_id}}">
<form class="hidden" data-sg-live-update-controls="hidden">
<input type="hidden" name="webapp_field_1_1" value="a,b">
<input type="hidden" name="webapp_field_1_1_match_type" value="OR">
</form>
{% comment %} Logic which will refuse to display any items until the correct filter is applied. {% endcomment %}
{% if params.webapp_field_1_1 != "a,b" %}
{%- include 'modules/siteglide_system/get/get_items', item_layout: 'item' -%}
{% endif %}
</section>PreviousSteps to Setting Up Live Updates API in a Module/WebApp LayoutNextSteps to Use Live Updates Methods
Last updated
Was this helpful?

