<h2>A note on Elements</h2>

<p>Craft allows plugins to create custom Element Types. Elements have the option to support URIs, but it is not required. Out of the box, Craft currently has 7 Element Types and only two of them (Entries, Categories) support URIs.  Here's a good <a href="https://straightupcraft.com/articles/master-the-element-types-craft-cms" rel="nofollow">overview of the default Elements</a>.</p>

<h2>Sprout Form Element Types and URIs</h2>

<p>Sprout Forms adds two new Elements to Craft. The <code>SproutForms_Form</code> Element and the <code>SproutForms_Entry</code> Element both which do not support URIs simply because we didn't feel there was a strong use case for them to be implemented for most form submission scenarios.</p>

<p>While it may not make sense to support URIs for all <code>SproutForm_Entry</code> Elements out of the box, you can still create a way for those Elements to be linked to in your templates, you will just have to do it manually.</p>

<h2>How to manually create URIs for Sprout Form Entry Elements</h2>

<p>To customize Craft to handle custom URLs for an Element that doesn't support URLs (of even for an Element that supports that that you need to do something fancy with), here is a rough example of the steps needed.</p>

<p>Loop through your Elements and output the URL you wish them to have to link to your Entries:</p>

<pre><code>/submissions/{{ formEntry.id }}
</code></pre>

<p>You will then need to <a href="https://craftcms.com/docs/routing" rel="nofollow">setup a route</a> to tell Craft which template it should load when it encounters a URL like that. You can create a route in the CP or in the <code>craft/config/routes.php</code> file. This route tells Craft to load the <code>submission/_entry.html</code> template each time a URL matches <code>submission/ANYTHING</code>:</p>

<pre><code>return array(
    'submissions/(?P&lt;formEntryId&gt;.*)' =&gt; 'submissions/_entry'
);
</code></pre>

<p>In your <code>submissions/_entry</code> template, you will need to use the ID information in the URL to query for the Form Entry that you wish to display:</p>

<pre><code>{% set entry = craft.sproutForms.getEntryById(formEntryId) %}
</code></pre>

<p>In the above example, we're able to use the <code>formEntryId</code> variable because we setup our route to assign the second segment of the URL to the value <code>formEntryId</code>. If you setup your route in the control panel, you may need to grab the ID using <code>getSegment</code>:</p>

<pre><code>{% set formEntryId = craft.request.getSegment(2) %}
{% set entry = craft.sproutForms.getEntryById(formEntryId) %}
</code></pre>

CC BY-SA 3.0
2016-08-05T13:52:22.240Z
Thanks for such a detailed answer. I also discovered I could do it with query strings. Links: `/entries?id={{ formEntry.id }}` and then `{% set id = craft.request.getparam('id') %} {% for entry in craft.sproutForms.entries.formHandle('entry').id(id) %}`
artmem
CC BY-SA 3.0
2016-08-05T15:02:55.680Z
Nice. Good catch. I overlooked the easy way that doesn't require the extra step with routes.
Ben Parizek
CC BY-SA 3.0
2016-08-04T23:46:09.733Z
2016-08-04T23:46:09.733Z
Ben Parizek
<p>I'm trying to build a front end to display entries collected through Sprout Forms. I want to create a list of all entry titles that can be clicked through to see the full entry.</p>

<p>I can list a single entry, or all entries:</p>

<pre><code>{% for formEntry in craft.sproutForms.entries.formHandle('entry') %}
  {{ formEntry.title }}
{% endfor %}
</code></pre>

<p>But when I try to create a link, {{ formEntry.url }} doesn't work. I'm not entirely sure if this is a Sprout Forms issue or a Craft routing issue, or if I'm just missing something obvious</p>

<elementcriteriamodel><routing><plugin-sproutforms>
Sprout Forms -- How to link to individual entries on the front-end
# Sprout Forms -- How to link to individual entries on the front-end

(Asked by: username_0 on 2016-08-04)

I'm trying to build a front end to display entries collected through Sprout Forms. I want to create a list of all entry titles that can be clicked through to see the full entry.
I can list a single entry, or all entries:
{% for formEntry in craft.sproutForms.entries.formHandle('entry') %}
  {{ formEntry.title }}
{% endfor %}

But when I try to create a link, {{ formEntry.url }} doesn't work. I'm not entirely sure if this is a Sprout Forms issue or a Craft routing issue, or if I'm just missing something obvious

**Tags:** elementcriteriamodel, routing, plugin-sproutforms

---

## 1 answers

### Answer by username_1 on 2016-08-04. Score: 2 | Accepted answer

A note on Elements
Craft allows plugins to create custom Element Types. Elements have the option to support URIs, but it is not required. Out of the box, Craft currently has 7 Element Types and only two of them (Entries, Categories) support URIs.  Here's a good overview of the default Elements.
Sprout Form Element Types and URIs
Sprout Forms adds two new Elements to Craft. The SproutForms_Form Element and the SproutForms_Entry Element both which do not support URIs simply because we didn't feel there was a strong use case for them to be implemented for most form submission scenarios.
While it may not make sense to support URIs for all SproutForm_Entry Elements out of the box, you can still create a way for those Elements to be linked to in your templates, you will just have to do it manually.
How to manually create URIs for Sprout Form Entry Elements
To customize Craft to handle custom URLs for an Element that doesn't support URLs (of even for an Element that supports that that you need to do something fancy with), here is a rough example of the steps needed.
Loop through your Elements and output the URL you wish them to have to link to your Entries:
/submissions/{{ formEntry.id }}

You will then need to setup a route to tell Craft which template it should load when it encounters a URL like that. You can create a route in the CP or in the craft/config/routes.php file. This route tells Craft to load the submission/_entry.html template each time a URL matches submission/ANYTHING:
return array(
    'submissions/(?P.*)' => 'submissions/_entry'
);

In your submissions/_entry template, you will need to use the ID information in the URL to query for the Form Entry that you wish to display:
{% set entry = craft.sproutForms.getEntryById(formEntryId) %}

In the above example, we're able to use the formEntryId variable because we setup our route to assign the second segment of the URL to the value formEntryId. If you setup your route in the control panel, you may need to grab the ID using getSegment:
{% set formEntryId = craft.request.getSegment(2) %}
{% set entry = craft.sproutForms.getEntryById(formEntryId) %}

> **Comments:**
> **username_0**: Thanks for such a detailed answer. I also discovered I could do it with query strings. Links: `/entries?id={{ formEntry.id }}` and then `{% set id = craft.request.getparam('id') %} {% for entry in craft.sproutForms.entries.formHandle('entry').id(id) %}`  
> **username_1**: Nice. Good catch. I overlooked the easy way that doesn't require the extra step with routes.  

---

