[SOLVED] 2 conditions in the range

Hello. I need help. I have 10 articles in the Section with content and 20 articles with custom param ‘go’. I want to publish articles with content only.

My code is

{{ range $index, .Paginator.Pages }}{{ .Render "blog_section.li" }}{{ end }}{{ range where (where .Site.RegularPages "Section" "blog") ".Params.go" "!=" "" }}{{ end }}					

but it doesn’t work.

where returns a collection on which you can use where again…

{{ $col1 := where .Pages "Type" "whatever" }}
{{ $col2 := where $col1 "Params.thing" "again_whatever" }}

Or as you’ll more commonly see it :

{{ range where ( where .Pages "Type" "whatever") "Params.thing" "again_whatever" }}

Hope this helps!

It does not work. I had replaced my code to

{{ range $index, .Paginator.Pages }}q<br/>{{ end }}{{ range where ( where .Pages "Section" "blog") "Params.go" "1" }}{{ end }}

and saw all the articles, but all articles do not have the parameter go with value ‘1’

In FM do you have it?

go: "1"

Without the quotes it will be a different data type.

Look. I added new variable - ‘redirect’.
Now I have two types of articles:

  1. +++
    layout = “blog_single_tpl”
    title = “7 Useful Options for Content Protection”
    date = “2017-10-18T00:00:00+03:00”
    redirect = 0
    +++

  2. +++
    layout = “301”
    title = “10% Discount on CDN from G-Core Labs”
    go = “/news/10-discount-on-cdn-for-new-customers/”
    redirect = 1
    +++

The code is

				<ul class="list_grid">
{{ range $index, .Paginator.Pages }}q{{ end }}{{ range where ( where .Pages "Section" "blog") "Params.redirect" 0 }}{{ end }}					
				</ul>
			{{ partial "pagination" . }}				

And it does not work. I see all articles.

My solve is

  1. My param must be in double quotes

redirect = “1”

  1. The condition is

{{ $paginator := .Paginate (where ( where .Pages “Type” “blog”) “Params.redirect” “0”) }}
{{ range $paginator.Pages }}
{{ .Render “blog_section.li” }}
{{ end }}