{% set last = namespace(val=0) %} {% for book in books %} {% set num = SeriesBookNum( series.id, book.id ) %} {% if num == None %} {# okay, if this is a parent book, the num == None, so make it use last real-book and add .01 to it to make sure it sorts just after the last one #} {% endfor %}
TitleBook Number
{% if book.parent_ref|length %} {% set style="visibility: hidden" %} {% endif %} {{book.title}} {% else %} {% endif %} {% for s in book.series %} {% if not book.child_ref|length %} {{ SeriesBookNum( s.id, book.id ) }} of {{s.title}}
{% endif %} {% if SeriesBookNum( s.id, book.id ) == 1 %} {% endif %} {% if SeriesBookNum( s.id, book.id ) == s.num_books %} {% endif %} {% set last.val = num %} {% endfor %}