Id

Id

{% id %}

Creates a "unique" identifier each time it is called. Each identifier consists only of lowercase letters, and each subsequent call simply increments it by 1 character (ie: 'aaa' -> 'aab' -> 'aac', etc...).

Identifiers created using this method are not random and therefore will not prevent caching. However, if the number of times the id method is called or if the arguments to the id method is changed the identifiers may not be consistent between page loads - which means that you should not rely on identifiers created using this method for styling or for creating sharable links.

{% id output_to_template? [var, set, or assign]? variable? output_to_template? [= attributes ]? %}

{% id
output_to_template
 
If included the id will be output directly to the template.
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this id is stored on. "var" is the default behavior.
variable
output_to_template
 
If included the id will be output directly to the template.
=
attributes
 
Key:value pairs with unique keys. May use the variable arguments syntax.
%}

attributes

prefix
 
String to prepend before the id
suffix
 
String to append after the id
length
 
The desired string length of the id, excluding the prefix and suffix
skip
 
Use this to skip past a specific id. Useful in edge-cases where you need to avoid identifiers before a specific value

{% auth change_id %}

Functions as an alternate init command if the old_id argument is supplied.

Sets the id for the profile to the id specified. If ths site is configured to set the id an email to the same value then this will validate the id as a valid email address and will set the email to this value as well.

Note that this does NOT log the profile out, deactivate it, or require any further confirmation or action by the user to continue using their profile. Those actions are up to the template developer to execute (which we strongly recommend whenever the email address is changed).

Sets {{ auth.id_changed }} to true if successful or false if not. If successful sets {{ auth.old_id }} and {{ auth.new_id }} to the old and new id values and sets {{ auth.id }} to the new id. Note that any future auth init commands will have to use the new id instead of the old one.

If successful and the site is configured to set the id and email to the same value then this also sets {{ auth.email_changed }} to true and sets {{ auth.old_email }} and {{ auth.new_email }} to the old and new email values.

If successful, the {% auth abort %} command may not be called.

{% auth change_id old_id? new_id %}

{% auth
change_id
old_id
 
The id of the profile to change
new_id
 
The new id for the profile May use liquid filters.
%}

Error Codes:
command_disabled: Indicates that the current method has been disabled at the site level. This will be set for any auth method if profiles are disabled.
duplicate_command: Indicates that the {% auth change_id %} method has already been called. It may only be called once per page load. If the site is configured to set the id and email to the same value then this error code may also indicate that the {% auth change_email %} method has already been called.
no_init: Indicates that no initialization method has been called yet and no value was provided to the old_id parameter.
bad_init: Indicates that another initialization function was called with a different id.
aborted: Indicates that the method could not be performed because {% auth abort %} has been called.
not_found: Indicates that no profile was found with the old id.
blocked: Indicates that the profile is currently blocked.
locked: Indicates that the profile is currently locked.
inactive: Indicates that the profile is currently inactive and must be activated first.
missing_value: Indicates that no new_id argument was supplied to the {% auth change_id %} method.
unchanged: Indicates that the id was not changed because it was the same as the old id.
duplicate_value: Indicates that another profile already exists with the new id.
unexpected: Indicates that the system encountered an unexpected error which is not due to any of the common issues associated with profiles. This is a rare error code but may be possible in edge cases such as duplicate concurrent requests, infrastructure issues, or suspected security incidents.

Examples

Save Id

Copy
<form id="{% id var form_id output_to_template = prefix:'myform_' %}">...</form>
<script type="text/javascript">var myform = document.getElementById('{{form_id}}'); ...</script>

Short Id

Copy
<div id="{% id = length:1 prefix:'myid_' %}">...</div>

Long Id

Copy
<div id="{% id = length:32 suffix:'_longidentifier' %}">...</div>

Skip Id

Copy
<div id="{% id = skip:'ffffffff' suffix:'images_' %}">
{% for image in entity.images %}
<div id="{% id var image_id output_to_template = length:8 prefix:'img_' %}">...</div>
{% endfor %}
</div>

Generate Id

Copy
<form id="{% id %}">...</form>