Answers.Body: <p>I had trouble fetching the versions entry data. Things like <code>version.dateUpdated</code> worked, but as soon as I tried to get the data of my custom fields, it would only return the latest data, not the one from the version.</p>
  
  <p>This is what made it work: fetch the version, get the entries version using <code>getVersionById()</code> (<a href="https://craftcms.com/classreference/services/EntryRevisionsService#getVersionById-detail" rel="nofollow noreferrer">docs</a>)</p>
  
  <pre><code>{# Get versions of an entry #}
  {% set lastVersions = craft.entryRevisions.getVersionsByEntryId(entry.id, entry.locale) %}
  
  {# Get the version id and fetch the entire entry #}
  {% set lastVersionId = lastVersions[0].versionId %}
  {% set lastVersionEntry = craft.entryRevisions.getVersionById(lastVersionId) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-24T19:36:17.057Z
Answers.LastActivityDate: 2017-02-24T19:36:17.057Z
Answers.UserDisplayName: medoingthings
Answers.Body: <p>Probably something very similar to what Craft does when displaying past entry revisions from a template in the control panel. :)</p>
  
  <p><a href="https://github.com/craftcms/cms/tree/master-v2/src/templates/entries/_revisions.html#L23-L36" rel="nofollow noreferrer">https://github.com/craftcms/cms/tree/master-v2/src/templates/entries/_revisions.html#L23-L36</a></p>
  
  <pre><code>{% if section.enableVersioning %}
      {% set versions = craft.entryRevisions.getVersionsByEntryId(entry.id, entry.locale) %}
      {% if versions %}
          &lt;h6&gt;{{ "Recent Versions"|t }}&lt;/h6&gt;
          &lt;ul class="padded"&gt;
              {% for version in versions %}
                  &lt;li&gt;&lt;a{% if entry.getClassHandle() == 'EntryVersion' and version.versionId == versionId %} class="sel"{% endif %} href="{{ url(baseUrl~'versions/'~version.versionId) }}"&gt;
                      {{ "Version {num}"|t({ num: version.num }) }}
                      &lt;span class="light"&gt;{{ version.dateCreated.uiTimestamp() }}, {{ version.creator }}&lt;/span&gt;
                  &lt;/a&gt;&lt;/li&gt;
              {% endfor %}
          &lt;/ul&gt;
      {% endif %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-22T23:35:46.393Z
Answers.LastActivityDate: 2018-02-21T23:44:10.737Z
Answers.LastEditDate: 2018-02-21T23:44:10.737Z
Answers.UserDisplayName: Brad Bell
Body: <p>Is it possible to output content from previous revisions of entries in the twig templates?</p>
  
  <p>I need to do a score comparison between say entry 1 and entry 1.1 to see if the value has increased then output an indicator on the front end to indicate the outcome (Up arrow or down arrow most likely) kind of like a music chart style.</p>
  
Tags: <templating><entries><entry-versions>
Title: Display old entry version content through twig?
ThreadText: # Display old entry version content through twig?
  
  (Asked by: username_0 on 2016-09-22)
  
  Is it possible to output content from previous revisions of entries in the twig templates?
  
  I need to do a score comparison between say entry 1 and entry 1.1 to see if the value has increased then output an indicator on the front end to indicate the outcome (Up arrow or down arrow most likely) kind of like a music chart style.
  
  **Tags:** templating, entries, entry-versions
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-02-24. Score: 1 | Accepted answer
  
  I had trouble fetching the versions entry data. Things like `version.dateUpdated` worked, but as soon as I tried to get the data of my custom fields, it would only return the latest data, not the one from the version.
  
  This is what made it work: fetch the version, get the entries version using `getVersionById()` ([docs](https://craftcms.com/classreference/services/EntryRevisionsService#getVersionById-detail))
  
  ```
  {# Get versions of an entry #}
  {% set lastVersions = craft.entryRevisions.getVersionsByEntryId(entry.id, entry.locale) %}
  
  {# Get the version id and fetch the entire entry #}
  {% set lastVersionId = lastVersions[0].versionId %}
  {% set lastVersionEntry = craft.entryRevisions.getVersionById(lastVersionId) %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2016-09-22. Score: 1
  
  Probably something very similar to what Craft does when displaying past entry revisions from a template in the control panel. :)
  
  <https://github.com/craftcms/cms/tree/master-v2/src/templates/entries/_revisions.html#L23-L36>
  
  ```
  {% if section.enableVersioning %}
      {% set versions = craft.entryRevisions.getVersionsByEntryId(entry.id, entry.locale) %}
      {% if versions %}
          <h6>{{ "Recent Versions"|t }}</h6>
          <ul class="padded">
              {% for version in versions %}
                  <li><a{% if entry.getClassHandle() == 'EntryVersion' and version.versionId == versionId %} class="sel"{% endif %} href="{{ url(baseUrl~'versions/'~version.versionId) }}">
                      {{ "Version {num}"|t({ num: version.num }) }}
                      <span class="light">{{ version.dateCreated.uiTimestamp() }}, {{ version.creator }}</span>
                  </a></li>
              {% endfor %}
          </ul>
      {% endif %}
  {% endif %}
  
  ```
  
  
  ---
  
  