Hello,
I’m currently trying to give my theme a new feature. I’m trying to use a Front Matter with name notaxonomy
and it should be an array to be possible to add more taxonomies. Every taxonomy that is listed in notaxonomy
should not be visible below the single.html.
I’ve already a loop that shows every taxonomy of a post and is configured in the config taxonomies
.
I tried a bit an this was an approach:
Important here is {{ if ne $taxolist $taxonomyname }}
this works as long as the notaxonomy
Front Matter is not a array.
Attempt
<div class="tags">
{{ if ne .Type "page" }}
{{ $pagename := .Page.Title }}
{{ $notaxo := .Params.notaxonomy }}
{{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
{{ with index $.Params $taxonomyname }}
{{ with ($.Site.GetPage (printf "/%s" $taxonomyname)) }}
{{ range $taxolist := $notaxo }}
{{ if ne $taxolist $taxonomyname }}
<div style="float:left; width:20%; border-top:1px solid #eee">
<p>{{ $taxonomyname | humanize }}</p>
</div>
<div style="float:right; width:80%; border-top:1px solid #eee">
<p>
{{ range $key, $value := $taxonomy }}
{{ range $value.Pages }}
{{ if eq .LinkTitle $pagename }}
<a href="/{{ $taxonomyname }}/{{ $key }}/"> {{ $key }} </a>
{{ end }}
{{ end }}
{{ end }}
</p>
</div>
<div style="clear:both"></div>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</div>
If I try the same with {{ if eq $taxolist $taxonomyname }}
it works like a charm but only shows the taxonomies listed in this array notaxonomy
.
I really want the new Front Matter to be optional and it should not show the taxonomies that are in this array
I hope somebody can help me with this.
Sincerely,
dataCobra