Erik
1
Hi, I am trying to sort the module list of secure zones assigned to a user alphabetically. Any ideas how we can solve it?
<ul>
{% for zone in request.currentmember.securezones %}
<li><a href="{% component type: "module", source: "Page", layout: "Page URL", filterBy: "id", filterValue: "{{zone.landingpageid}}" %}">{{zone.name}}</a></li>
{% endfor %}
Cheers, Erik
Hi @Erik
You can use a Liquid filter to sort a collection by a given property.
This should do the trick:
{% assign sortedZones = request.currentmember.securezones | sort: 'name' %}
<ul>
{% for zone in sortedZones %}
<li><a href="{% component type: "module", source: "Page", layout: "Page URL", filterBy: "id", filterValue: "{{zone.landingpageid}}" %}">{{zone.name}}</a></li>
{% endfor %}
</ul>
1 Like
Erik
3
Perfect, thank you! Your help is much appreciated as usual