Now, I need to make groups of posts, which are also ordered within that group.
So i ended adding a group and order param in every post*.md’s front matter I made.
What I want to achieve in the list.html of section1 is something like this:
Where all the posts are listed in order under their corresponding group, and all groups are listed in order also based in, for example, an array of groups declared maybe in _index.md.
Is this possible? I was messing with ranges, sort, .GroupBy, .ByParam, etc, without success
Thank you very much for the explanation!!!
I’ve already encountered that, but there’s two thing I need to do which the example is not covering. Maybe I’m thinking this wrong, so I’ll be glad if you could clear things a little for me.
order’s ok, it could be just a number so sorting them numerically/alphabetically will be the same and its correct.
As for groups, I’ll need to sort them based on a slice. And also will be perfect if only posts from groups present on the array are listed (as a safe-check).
Take into account I have a param defined in _index.md , groups: ["B", "D", "A", "C"]
I want to list groups in that order
This is untested, but maybe you could do something like:
<!-- Get the list of valid groups -->
{{ $page := .Site.GetPage "/section-1/_index.md" }}
{{ $groups := $page.Params.groups }}
...
<!-- Only list pages where group param is in groups list -->
{{ if in $groups .Params.group }}
...
{{ end }}
I have tried several of the suggestions from other posts but have not been able to achieve the objective.
arbitrarily ordered groups of page images
I can sort all the member pages in the correct order, by sorting on the sort_order. However, I can’t get a nice list of affiliations to place a header over each group.
execute of template failed: template: members/list.html:5:25: executing "content" at <.Pages.Params.affiliation>: can't evaluate field Params in type page.Pages
Taking the approach listed above, I tried to loop over the GroupByParam “affiliation” but nothing is output (perhaps I have not set up sections)?
Almost got the solution!!!
{{- range .Pages.GroupByParam "sort_order" }}
<h2>{{ .Key }}</h2>
{{- range .Pages.ByParam "affiliation" }}
<h3>{{ .Title }}</h3>
{{- end }}
{{- end }
Displays the correct order, with headers over each group! However, the header that is displayed is the sort_order, not the affiliation.
Suggestions on how to get the affiliation to display?