Property Values in JavaScript & Template Code#
Access via Template code#
All the values of the properties a user has entered via the Miva admin are available in the instance template using the following structure:
l.settings:instance
The l.settings:instance
is a structure containing all the property values of the component. It uses the codes you give to each property. For Example lets say we want to access the value the customer input for the subheading property
Variable
l.settings:instance
Entity
&mvte:instance:content:subheading:value;
Accessing via JavaScript#
The entire l.settings:instance
structure can be output to a JSON object which can them be used in your javascript files for your component.
<script>
var instance = <mvt:eval expr="miva_json_encode( l.settings:instance, '')" />;
// instance.content.subheading.value
</script>
Sequence and Flex Item Variables#
The following variables are available in page templates, which grant access to the flex item, sequence item, sequence item position in its own sequence, and sequence item position in all output sequence item lists. These variables are helpful to output identifying information to the page for testing scripts, javascript tracking (google analytics impressions), A/B testing, etc
Sequence Index/Pos#
l.settings:instance_pos
-
This is the current sequence-item position. It could be used to apply a counter
l.settings:total_instance_pos
-
This is the sequence-item position accounting for all sequences rendered on page
Flex Item#
data-flex-component="&mvte:flex_item:component_code;"
data-flex-item="&mvte:flex_item:item_code;"
-
Helps identify components for various uses (e2e tests, tracking, future custom logic)
Sequence Item#
data-sequence-id="&mvte:sequence_item:id;"
data-sequence-item="&mvte:sequence_item:item;"
-
This info can be used for e2e, javascript tracking (google analytics impressions), A/B testing, etc.