Answers.Body: <p>Just use a variable that has the same keys as the entry model will have.</p>
  
  <pre><code>{% set entries = [{title: 'hello', ...}, {title: 'hello2', ...}] %}
  
  {% for entry in entries %}
      {# stuff #}
  {% endfor %}
  </code></pre>
  
  <p>Then, when you want to move to using the database, just switch what  <code>entries</code> is set to:</p>
  
  <pre><code>{% set entries = craft.entries.section('service') %}
  </code></pre>
  
  <p>That way the template will still look exactly the same.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-24T10:02:15.010Z
Answers.LastActivityDate: 2017-04-24T10:02:15.010Z
Answers.UserDisplayName: megatrond
Answers.Body: <p>I'm not 100% sure I'm following what you're going for, if you want to access the array values of the <code>titel</code> property in the <code>service</code> variable, you'd do so like:</p>
  
  <p><code>service.title[0]</code>, which would equal <code>hallo</code> and <code>service.title[1]</code>, which would equal <code>hallo2</code>.</p>
  
  <p>So would look like:</p>
  
  <pre><code>{% for entry in craft.entries.section(service.title[0]) %}
  
    &lt;p&gt;{{ entry.titel }}&lt;/p&gt;
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-25T14:47:54.550Z
Answers.Text: thanks a lot brad, i think my question was a bit confusing.
Answers.UserDisplayName: HendrikEng
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-24T18:45:47.193Z
Answers.LastActivityDate: 2017-04-23T23:07:25.870Z
Answers.LastEditDate: 2017-04-23T23:07:25.870Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am trying to use Twig methods/loops while working on a design/template. To avoid touching the CP or the DB i did set variables directly in the template, like : </p>
  
  <pre><code>{% set service = 
    { 
      'titel': 
        [
          'Titel1', 
          'Titel2'
        ],
    }
  %}
  
  {% for i in 0..1 %}
    &lt;p&gt;{{ service.headerQuote }}&lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>It would be much better to be able to use the standard Craft methods, so if I move from templating/designing towards the DB i wouldn't have to touch the methods in my markup.  Unfortunately, I can't make it work... I tried:</p>
  
  <pre><code>{% set service = { titel: 
                     [ 
                       'hallo',
                       'hallo2' 
                      ]
                    } 
                  %}
  
  {% for entry in craft.entries
        .section('service') %}
  
        &lt;p&gt;{{ entry.titel }}&lt;/p&gt;
  
  {% endfor %}
  </code></pre>
  
  <p>I tried to set the service entry to craft.entries.section('service') but that doesn't work as well... what am I missing?</p>
  
  <p>Is it even possible to overwrite Craft variables in the markup?</p>
  
Tags: <templating><variable>
Title: Set Craft variables in the markup
ThreadText: # Set Craft variables in the markup
  
  (Asked by: username_0 on 2017-03-24)
  
  I am trying to use Twig methods/loops while working on a design/template. To avoid touching the CP or the DB i did set variables directly in the template, like :
  
  ```
  {% set service = 
    { 
      'titel': 
        [
          'Titel1', 
          'Titel2'
        ],
    }
  %}
  
  {% for i in 0..1 %}
    <p>{{ service.headerQuote }}</p>
  {% endfor %}
  
  ```
  
  It would be much better to be able to use the standard Craft methods, so if I move from templating/designing towards the DB i wouldn't have to touch the methods in my markup. Unfortunately, I can't make it work... I tried:
  
  ```
  {% set service = { titel: 
                     [ 
                       'hallo',
                       'hallo2' 
                      ]
                    } 
                  %}
  
  {% for entry in craft.entries
        .section('service') %}
  
        <p>{{ entry.titel }}</p>
  
  {% endfor %}
  
  ```
  
  I tried to set the service entry to craft.entries.section('service') but that doesn't work as well... what am I missing?
  
  Is it even possible to overwrite Craft variables in the markup?
  
  **Tags:** templating, variable
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-04-24. Score: 2 | Accepted answer
  
  Just use a variable that has the same keys as the entry model will have.
  
  ```
  {% set entries = [{title: 'hello', ...}, {title: 'hello2', ...}] %}
  
  {% for entry in entries %}
      {# stuff #}
  {% endfor %}
  
  ```
  
  Then, when you want to move to using the database, just switch what `entries` is set to:
  
  ```
  {% set entries = craft.entries.section('service') %}
  
  ```
  
  That way the template will still look exactly the same.
  
  
  ---
  
  ### Answer by username_2 on 2017-03-24. Score: 1
  
  I'm not 100% sure I'm following what you're going for, if you want to access the array values of the `titel` property in the `service` variable, you'd do so like:
  
  `service.title[0]`, which would equal `hallo` and `service.title[1]`, which would equal `hallo2`.
  
  So would look like:
  
  ```
  {% for entry in craft.entries.section(service.title[0]) %}
  
    <p>{{ entry.titel }}</p>
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: thanks a lot username_2, i think my question was a bit confusing.  
  
  ---
  
  