bwhli
May 7, 2020, 1:07pm
1
Hello, I have my index.html here .
I would like to have the pagination exclude pages. I thought the code below would allow me to do this, but it is still including the pages.
{{ $paginator := .Paginate (where .Data.Pages “Type” “not in” (slice “page”)) }}
{{ range $paginator.Pages }}
If you go to this page in my pagination index, you can see that there are pages being included.
Does anyone know what I’m doing wrong?
bep
May 7, 2020, 1:11pm
2
I remember vaguely that we at some point removed the ERROR message when you create several paginators on the same page, but with different arguments.
The thing is, if you do:
{{ $paginator := .Paginator }}
{{ $paginator := .Paginate (where .Data.Pages “Type” “not in” (slice “page”)) }}
{{ range $paginator.Pages }}
You will get the unfiltered result fuirom the first invocation. The above can be a little hard to debug.
bwhli
May 7, 2020, 1:26pm
3
Thanks for the quick reply @bep ! Can you let me know where you are seeing the first {{ $paginator := .Paginator }}?
bwhli
May 7, 2020, 1:43pm
4
Ah, looks like this in baseof.html might be causing issues.
{{- if eq .RelPermalink “/” -}}
{{- if ne .Paginator.PageNumber 1 -}}
{{- end -}}
{{- end -}}
bep
May 7, 2020, 2:01pm
5
I only see what you have posted, which I suspect isn’t everything – hence I’m guessing a little.
bwhli
May 7, 2020, 2:11pm
6
Sorry, I linked the repo in the post as well. Anyway, your comment reminded me of another .Paginator in another file that was causing the issue. Thank you!