Hello,
I am trying to create a list of events per year.
- Event data is stored in toml files in the data folder.
- One file per year
When I try to get the data from only one file it works.
Unfortunately if I try to hand over the event year to the site using .Params.event it is not working.
I was reading everything I could find being similar to my topic but didn’t get it working
My files are like this (showing the parameter I tried to use to address the data file)
2012.md
event: “Termine2012”
my data:
Termin2012.toml
dates = [
"Date 1",
"Date 2",
"Date 3"
]
names = [
"Name 1",
"Name 2",
"Name 3"
]
desc = [
"Desc 1",
"Desc 2",
"Desc 3"
]
My Single.html for those events calls a partial:
<div class="mdl-color-text--grey-700 mdl-card__supporting-text hugo-content">
{{ .Content }}
<!-- get termine from toml files -->
{{ partial "termine-table.html" . }}
<!-- End data access -->
</div>
Partial file includes the table asking for the data:
<div id="termin-table" class="colmask threecol">
<div class="colmid">
<div class="colleft">
<div class="col1">
<!-- Column 1 start -->
{{ $event := .Params.event }}
{{ if isset $.Site.Data $event }}
{{ $MyDateNames := (index $.Site.Data $event).names }}
{{ end }}
{{ range $MyDateNames}}
<ul>
<li>{{ . }}</li>
</ul>
{{ end }}
<!-- Column 1 end -->
</div>
<div class="col2">
<!-- Column 2 start -->
{{ range $.Site.Data.Termin2012.dates }}
<ul>
<li>{{ . }}</li>
</ul>
{{ end }}
<!-- Column 2 end -->
</div>
<div class="col3">
<!-- Column 3 start -->
{{ range $.Site.Data.Termin2012.desc }}
<ul>
<li>{{ . }}</li>
</ul>
{{ end }}
<!-- Column 3 end -->
</div>
</div>
</div>
</div>
column 1 shows how I tried to get the event name from the front matter file 2012.md
column 2 and 3 show how it was working with getting data from one file only.
the error message I do get is that my variable $MyDateNames is undefined.