<p>You do not need to create a separate section for course work.</p>

<p>What you want to have is two different urls, that both display the same entry, but in two different ways, with two different templates. So for example <code>/course-slug</code> will be the url for info page for the entry with slug <code>course-slug</code>, and <code>/course-slug/lesson</code> will be the url for the work page for the entry.</p>

<p>If you think of this as two different routes, you have set one of those routes up in the course section. You can set up a second one as a <a href="https://craftcms.com/docs/routing#dynamic-routes" rel="nofollow noreferrer">dynamic route</a>. You want to route <code>[slug]/lesson</code> (uri) to <code>_work</code> (template) (or whatever your template is). Then in the <code>_work.twig</code> template, you will need to fetch the entry from the slug:</p>

<pre><code>{% set entry = craft.entries.section('course').slug(slug).first() %}
</code></pre>

<p>Check if no entry is set, and if not <code>{% exit 404 %}</code>. And then proceed as normal.</p>

CC BY-SA 3.0
2018-03-08T20:31:23.810Z
This worked exactly the way I needed. I hadn't checked out dynamic routes yet. Thank you!
FuzzyJelly
CC BY-SA 3.0
2018-03-08T19:46:20.917Z
2018-03-08T19:46:20.917Z
Marion Newlevant
<p>I'm building a coursework site and have a Course section, who's entries will be courses containing work that the client will assign to users. I built in both the work itself (different "lessons" sections), and fields for the info page that will be displayed to all users of the site.</p>

<p>How can I use two different templates with the same entry? I need to be able to link to the course.url for the info page, as well as the course.url for the work page within the different templates that use info from the courses.</p>

<p>Currently I have all of the course entries urls going to the info page template. Do I need to create a separate section for course work? </p>

CC BY-SA 3.0
2018-03-08T18:52:41.297Z
Do you know twigs `{% extends %}` and `{% include %}` and `{% block %}` tags? These do exactly what you want
Robin Schambach
<templating><entries><url><sections>
How can I use two different templates for a single entry?
# How can I use two different templates for a single entry?

(Asked by: username_0 on 2018-03-08)

I'm building a coursework site and have a Course section, who's entries will be courses containing work that the client will assign to users. I built in both the work itself (different "lessons" sections), and fields for the info page that will be displayed to all users of the site.

How can I use two different templates with the same entry? I need to be able to link to the course.url for the info page, as well as the course.url for the work page within the different templates that use info from the courses.

Currently I have all of the course entries urls going to the info page template. Do I need to create a separate section for course work?

**Tags:** templating, entries, url, sections

> **Comments:**
> **username_1**: Do you know twigs `{% extends %}` and `{% include %}` and `{% block %}` tags? These do exactly what you want  

---

## 1 answers

### Answer by username_2 on 2018-03-08. Score: 1 | Accepted answer

You do not need to create a separate section for course work.
What you want to have is two different urls, that both display the same entry, but in two different ways, with two different templates. So for example /course-slug will be the url for info page for the entry with slug course-slug, and /course-slug/lesson will be the url for the work page for the entry.
If you think of this as two different routes, you have set one of those routes up in the course section. You can set up a second one as a dynamic route. You want to route [slug]/lesson (uri) to _work (template) (or whatever your template is). Then in the _work.twig template, you will need to fetch the entry from the slug:
{% set entry = craft.entries.section('course').slug(slug).first() %}

Check if no entry is set, and if not {% exit 404 %}. And then proceed as normal.

> **Comments:**
> **username_0**: This worked exactly the way I needed. I hadn't checked out dynamic routes yet. Thank you!  

---

