Object: phones
Variables
Phones Object
.all
List of all available phone numbers in the particular context.
Examples
CODE{% if session.user %}
{% for phone in session.user.account.phones.all %}
{{ phone.type }}: {{ phone.number }} <br/>
{% endfor %}
{% else %}
not signed in, cannot list phone numbers
{% endif %}
OUTPUTmobile: 083-100-2000
office: 011-123-4567
...
.by_type
List of all available phone numbers of a particular type. There are 4 types of phone numbers: mobile, home, office and unknown
Examples
CODE{% if session.user %}
{% for phone in session.user.account.phones.by_type.mobile %}
{{ phone.type }}: {{ phone.number }} <br/>
{% endfor %}
{% else %}
not signed in, cannot list mobile phone numbers
{% endif %}
OUTPUTmobile: 083-100-2000
...
Phone List Object
.has
Evaluates to true if there is at least one phone number in the list.
Examples
CODE{% if session.user %}
{% if session.user.account.phones.by_type.mobile.has %}
user has mobile phone(s)<br/>
{% else %}
user does NOT have mobile phone<br/>
{% endif %}
{% else %}
not signed in, cannot access phone list
{% endif %}
OUTPUTuser has mobile phone(s)
.size
Number of phone numbers in the list.
Examples
CODE{% if session.user %}
user has {{ session.user.account.phones.by_type.mobile.size %} mobile numbers
{% else %}
not signed in, cannot access phone list
{% endif %}
OUTPUTuser has mobile phone(s)
.first
Access to the first phone number in the list.
Examples
CODE{% if session.user %}
{% if session.user.account.phones.by_type.mobile.has %}
first mobile number is {{ session.user.account.phones.by_type.mobile.first.number %}
{% else %}
user has not mobile numbers
{% endif %}
{% else %}
not signed in, cannot access phone list
{% endif %}
OUTPUTfirst mobile number is 083-100-2000
.all
All phone numbers in the list.
Examples
CODE{% if session.user %}
{% for phone in session.user.account.phones.by_type.mobile.all %}
mobile number: {{ phone.number %}
{% endfor %}
{% else %}
not signed in, cannot access phone list
{% endif %}
OUTPUTmobile number: 083-100-2000
mobile number: 083-100-2001
...
.filter.<key>.<value>
Filter phone numbers by a field. Filtering is usually done on metafield values, and it requires that the metafield name and value conform to reference name constraints, that is, contains only alpha-numeric, dashes and underscores. Multiple fiters can be applies after each other, narrowing down the result progressively.
To specify the filtering criteria, add two elements to the path, one for the key and the other for the value. For example, lets say there is a number with a metafield key of use, and value of sms. To filter for a number matching this criteria, specify at the end of the access path something like ... .filter.use.sms
. This will return a phone list containing all numbers having a metafield named use set to sms.
Examples
CODE{% if session.user %}
use for sms: {{ session.user.account.phones.by_type.mobile.filter.use.sms.first.number %}
{% else %}
not signed in, cannot access phone list
{% endif %}
OUTPUTuse for sms: 083-100-2000
Phone Object
.type
The type of the phone number. This is typically set to mobile, home, office or unknown.
Examples
CODE{% if session.user %}
type of first number: {{ session.user.account.phones.all.first.type %}
{% endif %}
OUTPUTtype of first number: mobile
.number
The phone number.
Examples
CODE{% if session.user %}
first phone number: {{ session.user.account.phones.all.first.number %}
{% endif %}
OUTPUTfirst phone number: 083-100-2001