HUGO

Where + in + Param.lang

Hello. Help me, please. I need to show posts with EN langs.

For example, I have a .MD file with Param show_lang

show_lang = ['de', 'en']

I have a condition

{{ range (where (where .Pages "Type" "cases") "Params.show_lang" "in" .Lang) }}
{{ .Params.show_lang }}
{{ end }}

But nothing is visible.

What is .Lang?

.Lang is a current language on the site.

on this page .Lang = ‘en’

{{ range where (where .Pages "Type" "cases") "Params.show_lang" "intersect" (slice .Lang) }}

Wonderful!

What about pagination?

My code is

{{ $paginator := .Paginate (where (where .Pages "Type" "cases") "Params.show_lang" "intersect" (slice .Lang)) 10 }}
{{ range $k, $v := $paginator.Pages }}
test
{{ end }}

Does this code reside in a list template or in a single-page template?

It is for list template.

Then it looks like it should work, assuming you are calling a pagination template to create the UI.

Yes, it is work. Sorry, my mistake.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.