Hi,
I’m getting back to a previous question I had. My question was “how to get a color variable and display it depending on the month name”. So this worked very well
But this code display the same color for each month (e.g. January 2017, Januray 2018, January 2019 have the same color). I try to get a different variable name for each of my year table. My idea was to point on the section from the bueprint to select the right variable :
couleurssection: <---My first section
label: Couleurs 2017
type: headline
janvier:
label: Janvier
type: color
fevrier:
label: Février
type: color
[.....etc.....]
couleurssection2: <---My second section
label: Couleurs 2018
type: headline
janvier2:
label: Janvier
type: color
fevrier2:
label: Février
type: color
....
So, how can I select my variable depending on the section from blueprint, something like
If they all have different names, you might as well refer to those fields by their names, no need for the sections at all. However, I’d probably use structure fields, anyway.
One question, though: For how many years do you want to add colors? What happens in two years’ time? Will you add more fields?
This seems to be exacly what I’m looking for. I renamed every fields, However I get
Notice: Undefined property: Site::$janvier in /Applications/MAMP/htdocs/MyProject/site/snippets/calendar.php on line 42 Fatal error: Uncaught Error: Call to undefined function 2017() in...
<?php
$monthC = str::ascii($month->name());
$annee = '2017';
$field = $monthC.$annee;
//let's check if this gives us what we think
dump($field);
$color = $site->$field();
?>