diff --git a/modules/blox/blox/portfolio/block.html b/modules/blox/blox/portfolio/block.html index ff01204f..f05a3d39 100644 --- a/modules/blox/blox/portfolio/block.html +++ b/modules/blox/blox/portfolio/block.html @@ -56,15 +56,6 @@ {{ $sort_order := cond $sort_ascending "asc" "desc" }} {{ $query = sort $query $sort_by $sort_order }} -{{/* Store total count before limiting */}} -{{ $total_count := len $query }} - -{{/* Limit */}} -{{ $count := partial "functions/coerce_int" (dict "value" (index $content "count") "default" 6 "min" 0) }} -{{ if gt $count 0 }} - {{ $query = first $count $query }} -{{ end }} - {{/* Get filter buttons */}} {{ $buttons_raw := index $content "buttons" }} {{ $buttons := slice }} @@ -86,6 +77,17 @@ {{ end }} {{ end }} +{{/* Store total count before limiting; keep full set when filtering so buttons work */}} +{{ $total_count := len $query }} +{{ $has_multiple_filters := gt (len $buttons) 1 }} + +{{/* Limit (only when not using multiple filters, since Alpine filters client-side) */}} +{{ $count := partial "functions/coerce_int" (dict "value" (index $content "count") "default" 6 "min" 0) }} +{{ if and (gt $count 0) (not $has_multiple_filters) }} + {{ $query = first $count $query }} +{{ end }} +{{ $displayed_count := len $query }} + {{/* Columns */}} {{ $columns := partial "functions/coerce_int" (dict "value" (index $design "columns") "default" 3 "min" 1 "max" 4) }} {{ $grid_class := "md:grid-cols-2 lg:grid-cols-3" }} @@ -390,9 +392,7 @@ {{ $archive := index $content "archive" }} {{ if not (reflect.IsMap $archive) }}{{ $archive = dict }}{{ end }} {{ $default_show_archive := false }} - {{ if gt $count 0 }} - {{ $default_show_archive = gt $total_count $count }} - {{ end }} + {{ $default_show_archive = gt $total_count $displayed_count }} {{ $show_archive_link := partial "functions/coerce_bool" (dict "value" (index $archive "enable") "default" $default_show_archive) }} {{ if and $show_archive_link $archive_page }} {{ $archive_link := "" }} diff --git a/modules/blox/blox/portfolio/schema.json b/modules/blox/blox/portfolio/schema.json index 94e3366c..d46cb49e 100644 --- a/modules/blox/blox/portfolio/schema.json +++ b/modules/blox/blox/portfolio/schema.json @@ -30,7 +30,7 @@ }, "count": { "type": "integer", - "description": "Maximum number of projects to display (0 means unlimited)", + "description": "Maximum number of projects to display when no filter buttons are used (0 means unlimited)", "minimum": 0, "default": 6 },