kolber / stacey

Cheap & easy content management
http://staceyapp.com
MIT License
1.04k stars 131 forks source link

Is it possible to sort by a specific field? #90

Closed boedlen closed 11 years ago

boedlen commented 11 years ago

Is it possible to sort by a specific field in Stacey?

Something like

{% for child in page.children | sort('author') %}
  <li>
    <a href="{{ child.url }}">{{ child.title }}</a>
  </li>
{% endfor %}

I cannot find any documentation about this function aside from a headline in the Wiki.

kolber commented 11 years ago

Hey Martin, as it happens there is a custom Twig method which can do this called sortby. https://github.com/kolber/stacey/blob/master/extensions/twig-extensions.inc.php#L150

The usage is {% for child in sortby(page.children, 'author') %}