Answers.Body: <ol>
  <li><p>Define "best". It's one way of doing it but has a couple of issues. They need to log in to see this (I presume, otherwise one issue is that there are public facing things on the website no actual visitor cares about) but it's not in the dashboard. So there's a log in then navigate to the front end and get the page workflow which is less than ideal) Why not just put them in a <a href="https://docs.craftcms.com/v3/globals.html" rel="nofollow noreferrer">global</a> table field and let the client view/copy/edit them there?</p></li>
  <li><p>Your merge needs square brackets. You're trying to merge an object not an array. Try</p></li>
  </ol>
  
  <pre><code>{% set theRows = craft.entries.section('theSection').one() %}
  {% set siteVariables = [] %}
  {% for row in theRows %}
    {% set siteVariables = siteVariables | merge([{ (row.name): row.value}]) %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-30T19:11:19.210Z
Answers.Text: I hadn't investigated Globals in the past. Thanks so much for the tip! :)
Answers.UserDisplayName: Document Services
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-27T22:13:45.033Z
Answers.LastActivityDate: 2020-04-01T10:59:35.297Z
Answers.LastEditDate: 2020-04-01T10:59:35.297Z
Answers.UserDisplayName: billythekid
Body: <p>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.</p>
  
  <p>1) Is this this best way to do this?</p>
  
  <p>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...</p>
  
  <pre><code>{% set theRows = craft.entries.section('theSection').one() %}
  {% set siteVariables = [] %}
  {% for row in theRows %}
    {% set siteVariables = siteVariables | merge({ (row.name): row.value}) %}
  {% endfor %}
  </code></pre>
  
  <p>My section entry query is coming up blank and dumping <code>siteVariables</code> causes a server error.  The set up seems the same as a working installation. Am I missing something? <code>craft.entries.sectionId(ID).one()</code> also doesn't see to work...</p>
  
Tags: <craft3><entries>
Title: Global Site Variables (Static Page?)
ThreadText: # Global Site Variables (Static Page?)
  
  (Asked by: username_0 on 2020-03-27)
  
  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...
  
  **Tags:** craft3, entries
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-03-27. Score: 1 | Accepted answer
  
  1. Define "best". It's one way of doing it but has a couple of issues. They need to log in to see this (I presume, otherwise one issue is that there are public facing things on the website no actual visitor cares about) but it's not in the dashboard. So there's a log in then navigate to the front end and get the page workflow which is less than ideal) Why not just put them in a [global](https://docs.craftcms.com/v3/globals.html) table field and let the client view/copy/edit them there?
  2. Your merge needs square brackets. You're trying to merge an object not an array. Try
  
  ```
  {% set theRows = craft.entries.section('theSection').one() %}
  {% set siteVariables = [] %}
  {% for row in theRows %}
    {% set siteVariables = siteVariables | merge([{ (row.name): row.value}]) %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: I hadn't investigated Globals in the past. Thanks so much for the tip! :)  
  
  ---
  
  