collection.en.md 6.16 KB
Newer Older
1 2
---
title: Shapes
3
icon: icon.png
4 5 6 7 8 9 10 11 12 13
filter: filter-shapes

content:
    items:
        - '@taxonomy.function': shape_2D
        - '@taxonomy.function': shape_3D
    filter:
        published: true
        type: 'tech' 
    order:
14 15
        by: header.taxonomy.partcount
        dir: asc
16 17 18
    limit: 12
    pagination: true

19 20 21 22 23 24 25 26 27 28 29 30
########################################################################
# Needed because size of paginated collection can't be queried
# See issue https://github.com/getgrav/grav-plugin-pagination/issues/29
unpaginated:
    items:
        - '@taxonomy.function': shape_2D
        - '@taxonomy.function': shape_3D
    filter:
        published: true
        type: 'tech' 
########################################################################

31 32 33
form:
    name: filter-shapes
    id: items-filter
34
    classes: row
35 36 37 38 39
    fields:
        -
            name: filter
            type: fieldset
            id: filter
40
            classes: "col-12 col-md-6 text-center text-md-left"
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
            fields:
                -
                    name: shape_type
                    label: Type
                    type: select
                    id: shape_type
                    classes: custom-select
                    options:
                        'all':    'All Types'
                        'all-1':  '-----------------'
                        '2D':     '2D   | All Forms'
                        '2D:3':   '2D.3 | Triangle'
                        '2D:4':   '2D.4 | Rectangle'
                        '2D:5':   '2D.5 | Pentagon'
                        '2D:6':   '2D.6 | Hexagon'
                        '2D:7':   '2D.7 | Heptagon'
57
                        '2D:8':   '2D.8 | Octagon'
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
                        '2D:_9up': '2D.+ | Circle'
                        'all-2':  '-----------------'
                        '3D':     '3D   | All Bodies'
                -
                    name: shape_segsize
                    label: Parts
                    type: select
                    id: shape_segsize
                    classes: custom-select
                    options:
                        'all': 'All Sizes'
                        '1':   '1 per segment'
                        '2':   '2 per segment'
                        '3':   '3 per segment'
                        '4':   '4 per segment'
                        '5':   '5 per segment'
                        '6':   '6 per segment'
                        '7':   '7 per segment'
                        '8':   '8 per segment'
                        '_9up': 'more parts'
        -
            name: sorting
            type: fieldset
            id: sorting
82
            classes: "col-12 col-md-6 text-center text-md-right"
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
            fields:
                - 
                    name: order_by
                    label: Order By
                    type: select
                    id: order_by
                    classes: custom-select
                    default: 'header.taxonomy.partcount'
                    options:
                        'title': 'by Title'
                        'date': 'by Date Added'
                        'modified': 'by Date Modified'
                        'header.taxonomy.partcount': 'by Part Count'
                        'random': 'in Random Order'
                -
                    name: order_dir
                    label: Order Direction
                    type: select
                    id: order_dir
                    classes: custom-select
                    default: 'asc'
                    options:
                        'asc': 'Up'
                        'desc': 'Down'
    buttons:
        submit:
            value: Filter
    process:
        redirect: >-
112
            /en/techs/shapes/{% 
113 114 115 116 117 118 119 120 121
                set shape_segsize = form.value.shape_segsize                                        %}{%
                set shape_segsize = shape_segsize[:3] == 'all' ? 'all' : shape_segsize              %}{%

                set shape_type     = form.value.shape_type                                          %}{%
                set shape_segments = shape_type[2:1] != ':' ? 'all' : shape_type[3:]                %}{%
                set shape_type     = shape_type[:3] == 'all' ? 'all' : 'shape_' ~ shape_type[:2]    %}{%

                if shape_type == 'all'                                                              %}{%
                    if shape_segsize != 'all'                                                       %}{%
122 123
                        set filter = 'shape_segsize:' ~ shape_segsize  ~ '/'                        %}{%
                    endif                                                                           %}{%
124 125 126 127 128
                else                                                                                %}{%
                    if shape_segsize == 'all' and shape_segments == 'all'                           %}{%
                        set filter = 'function:' ~ shape_type  ~ '/'                                %}{%
                    else                                                                            %}{%
                        if shape_segments != 'all'                                                  %}{%
129
                            set filter = shape_type ~ '_segments:' ~ shape_segments ~ '/'           %}{%
130 131 132 133 134 135 136 137 138 139 140
                        endif                                                                       %}{%

                        if shape_segsize != 'all'                                                   %}{%
                            set filter = filter ~ shape_type ~ '_segsize:' ~ shape_segsize  ~ '/'   %}{%
                        endif                                                                       %}{%
                    endif                                                                           %}{%
                endif                                                                               %}{{ filter }}{%
                set order_by = form.value.order_by                                                  %}{%
                set order_dir = form.value.order_dir                                                %}{%
                set ordering = 'orderby:' ~ order_by ~ '/orderdir:' ~ order_dir                     %}{{ ordering }}
---