<p>Something like this might work.</p>

<pre><code>{% if not craft.request.isAjax %}

    {% set versions = craft.entryRevisions.getVersionsByEntryId(entry.id, entry.locale) %}

    Versions: 
    &lt;select class="js-versions-dropdown"&gt;
        &lt;option value=""&gt;Current&lt;/option&gt;
        {% for versionEntry in versions %}
            &lt;option value="{{ versionEntry.versionId }}"&gt;Version {{ loop.index }} ({{ versionEntry.postDate|date('m-d-Y') }} )&lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;

{% endif %}

{% if craft.request.isAjax %}

    {% if craft.request.param('versionid') %}
        {% set entry = craft.entryRevisions.getVersionById(craft.request.param('versionid')) %}
    {% endif %}

{% endif %}

&lt;div&gt;
    {{ entry.title }}
    ...
&lt;/div&gt;
</code></pre>

<p>In this example, you would want to listen for an <code>onChange</code> event on the dropdown list and reload the template via ajax, passing the 'versionid' as a post variable. Alternatively you could also just reload the whole page, in which case remove the 'if ajax' stuff. In this case, you'll probably also need to add some logic to the drop-down list so as to display the correct 'selected' option in the list.</p>

CC BY-SA 3.0
2015-04-06T18:07:04.963Z
This is perfect. Thank you! Is there any way to just list each versions contents without ajax? I tried using `{{versionEntry.fieldName}}` in the for loop but it just output the same value as the current version even though the field has different values for different versions.
ntoombs19
CC BY-SA 3.0
2015-04-07T00:27:25.377Z
Should work fine without ajax — as a test I was able to use {{ versionEntry.title }} in the for loop and display the different version titles just fine. Not sure why your not seeing the different content — you might double check the saved version content.
Douglas McDonald
CC BY-SA 3.0
2015-04-06T17:08:14.827Z
2015-04-06T17:35:33.750Z
2015-04-06T17:35:33.750Z
Douglas McDonald
<p>When editing an entry from the control panel you can switch versions of the entry. I would like to do the same thing but on the front end. Is there any way to do this using native craft functionality or do I need to use a plugin.</p>

<plugins>
How can I display entry edit history on the front end?
# How can I display entry edit history on the front end?

(Asked by: username_0 on 2015-04-06)

When editing an entry from the control panel you can switch versions of the entry. I would like to do the same thing but on the front end. Is there any way to do this using native craft functionality or do I need to use a plugin.

**Tags:** plugins


---

## 1 answers

### Answer by username_1 on 2015-04-06. Score: 2 | Accepted answer

Something like this might work.
{% if not craft.request.isAjax %}

    {% set versions = craft.entryRevisions.getVersionsByEntryId(entry.id, entry.locale) %}

    Versions: 
    
        Current
        {% for versionEntry in versions %}
            Version {{ loop.index }} ({{ versionEntry.postDate|date('m-d-Y') }} )
        {% endfor %}
    

{% endif %}

{% if craft.request.isAjax %}

    {% if craft.request.param('versionid') %}
        {% set entry = craft.entryRevisions.getVersionById(craft.request.param('versionid')) %}
    {% endif %}

{% endif %}


    {{ entry.title }}
    ...


In this example, you would want to listen for an onChange event on the dropdown list and reload the template via ajax, passing the 'versionid' as a post variable. Alternatively you could also just reload the whole page, in which case remove the 'if ajax' stuff. In this case, you'll probably also need to add some logic to the drop-down list so as to display the correct 'selected' option in the list.

> **Comments:**
> **username_0**: This is perfect. Thank you! Is there any way to just list each versions contents without ajax? I tried using `{{versionEntry.fieldName}}` in the for loop but it just output the same value as the current version even though the field has different values for different versions.  
> **username_1**: Should work fine without ajax — as a test I was able to use {{ versionEntry.title }} in the for loop and display the different version titles just fine. Not sure why your not seeing the different content — you might double check the saved version content.  

---

