On various Craft sites, I've needed to provide my clients with access to certain variables used across the site. Things like open hours, specific seasonal color palettes, on / off operation toggles. In the past I have made a Static page that has a single table field with name and value pairs. I have then retrieved these values at the start of my layout template and output them on various pages as needed.
1) Is this this best way to do this?
2) Related question (and more pressing): For a recent project, I have been unable to grab the variables as I've done in the past. Not sure why...
{% set theRows = craft.entries.section('theSection').one() %}
{% set siteVariables = [] %}
{% for row in theRows %}
{% set siteVariables = siteVariables | merge({ (row.name): row.value}) %}
{% endfor %}
My section entry query is coming up blank and dumping siteVariables
causes a server error. The set up seems the same as a working installation. Am I missing something? craft.entries.sectionId(ID).one()
also doesn't see to work...