Now for the layout of the /qa/volvo/ page, I want to show all content from its subsections (/qa/volvo/modelA/ and /qa/volvo/modelB/). Of course, the .IsDescendant method (from the page variables) seems perfectly capable for that task.
Except that I cannot come up with a where filter that works with .IsDescendant. For instance:
error calling where: IsDescendant is a method of type *hugolib.Page but doesn’t satisfy requirements
Some of the other angles I considered:
The .Section page variable doesn’t help here, since it only returns the top most section ("qa" in my case).
.Paginator.Pages only paginates the pages in the section itself, not those of its subsections.
I couldn’t find another page variable that I could use to infer which subsection a post falls into.
Who knows how I can paginate all posts from the subsections?
(My apologies if it’s basic question or I overlooked something simple; I’ve tried many approaches but now don’t know what ‘up’ and ‘down’ is anymore. )
Thanks for that interesting link. It does suggest that .IsDescendant is one valid way to check whether a page belongs to a section higher up the hierarchy or not.
Hopefully there’s also a workaround that gives something we can paginate.
I think the answer might be in .Sections, because that page variable returns the sections that fall below the current content.
For the /qa/volvo/ page, that would be the /qa/volvo/modelA/ and /qa/volvo/modelB/ sections. (And that’s indeed how it works in my theme.)
And so to see if any page of the website (.Site.RegularPages) falls in a subsection of the current page, I’d code that like so:
{{ range where .Site.RegularPages ".CurrentSection" "in" .Sections }}
{{ .RelPermalink }}<br>
{{ end }}
Unfortunately this doesn’t yield an outcome, which surprises me a little bit. Both .CurrentSection and .Sections yield a page, although the first returns one page and the latter can return multiple. But either way in compares are page with a page here.
Edit: I’m coming very close with the following code:
This performs the filtering exactly like I want it. But unfortunately, this triggers the “error calling Paginate: invoked multiple times with different arguments” error message, even though I do use the .CurrentSection.Title variable to generate a different where filter on each section page.