<p>First you'll want 3 templates — I'll call them 'news/index.html', 'news/_entry.html', and 'news/_extra.html'. (fyi... using an underscore before the template name is good practice as it prevents the template from being loaded directly; which would likely throw an error because no entry would be defined.)</p>

<p>You'll then want to create a custom route to the 'extra' page in settings, using the 'slug' token for one of the segments.</p>

<ul>
<li>If your url looks like this: news/slug/extra (where 'slug' is the slug token)</li>
<li>Load this template: news/_extra.html</li>
</ul>

<p>In the '_entry.html' template, you'll want to check your 'additional' field and create a link to your '/extra' page. Note: 'entry.url' should already include the 'news/slug' portion of the uri — we'll just be adding the '/extra' segment.</p>

<pre><code>{% if entry.additional %}
    &lt;a href="{{ entry.url ~ '/extra' }}"&gt;extra page&lt;/a&gt;
{% endif %}
</code></pre>

<p>In the '_extra.html' template, there should now be a 'slug' variable available to your entry.</p>

<pre><code>{% set newsEntry = craft.entry.section('news').slug(slug) %}
{% set newsIndex = craft.entry.section('pages').slug('news') %}
{{ newsIndex.title }} — {{ newsEntry.title }}
</code></pre>

<p>Note: I don't know in what section your 'news' index page is. I just picked something at random — you'll need to change that to match your structure.</p>

CC BY-SA 3.0
2015-05-01T01:55:01.050Z
To clarify your final note, the news index page in this example would belong to news. In relation to the actual template folder structure what I have is as follows: root = news.html then a folder called News with two templates inside called news_entry.html and news_extra.html – So in your example you use news/index.html, when it should be news.html – Did this match your understanding? Thank you for your answer and for pointing me in the right direction on this.
Craftnoob
CC BY-SA 3.0
2015-05-01T02:50:02.740Z
Yes. You can change the templates/paths to anything you want. I just used those as an example. I would still recommend placing an underscore in front of any templates that rely on an entry being defined however (i.e. '_news_entry.html' and '_news_extra.html').
Douglas McDonald
CC BY-SA 3.0
2015-05-01T04:08:01.120Z
I have renamed the last segment of Craft code as follows: {% set newsEntry = craft.entry.section('news').slug(slug) %}
{% set newsIndex = craft.entry.section('news').slug('news') %}
{{ newsIndex.title }} — {{ newsEntry.title }} - I am not sure where exactly to put this, and know that it is why {{ entry.newsExtra }} isn't loading in any information on the _extra.html page. The url which the user clicks on to see the extra page reads _extra.html - does this have to be the case, can it be made prettier without underscores while also taking your advice at the template side?
Craftnoob
CC BY-SA 3.0
2015-05-01T06:27:18.223Z
The {{ newIndex.title}} and {{ newsEntry.title}} are just an example to show you that you can access those entries as needed from your '_extras.html' template. Change to whatever you need. As far as the uri is concerned—you shouldn't have '_extra' in the uri, only in the route template definition. The uri should be 'news/{slug}/extra' where slug is the title of your news entry.
Douglas McDonald
CC BY-SA 3.0
2015-04-29T09:49:25.213Z
2015-04-29T09:49:25.213Z
Douglas McDonald
<p>I have a section where each item has its own URL e.g:
news/{slug}</p>

<p>The Entry Template for this section is:
news/news_detail</p>

<p>For each post I would like to have a link to a unique page which is populated with information from the fields from the parent post/group, e.g news.</p>

<p>The slug would look something like:
news/{slug}/extra</p>

<p>The Entry Template for the news_detail page has a rich text field:
additional</p>

<p>To make this more complicated, the link to this page will be visible only if the "additional" field is populated with data.
And finally each "extra" page should have a link back to the originating post.</p>

<p>I had considered using a simple JavaScript toggle, but having urls for the content is more important in this instance, so not an option.</p>

<p>Thank you for any pointers as I am not sure where to start.</p>

<templating><entries><field><slug>
How to create an auxiliary page with sub url?
# How to create an auxiliary page with sub url?

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

I have a section where each item has its own URL e.g:
news/{slug}

The Entry Template for this section is:
news/news\_detail

For each post I would like to have a link to a unique page which is populated with information from the fields from the parent post/group, e.g news.

The slug would look something like:
news/{slug}/extra

The Entry Template for the news\_detail page has a rich text field:
additional

To make this more complicated, the link to this page will be visible only if the "additional" field is populated with data.
And finally each "extra" page should have a link back to the originating post.

I had considered using a simple JavaScript toggle, but having urls for the content is more important in this instance, so not an option.

Thank you for any pointers as I am not sure where to start.

**Tags:** templating, entries, field, slug


---

## 1 answers

### Answer by username_1 on 2015-04-29. Score: 2

First you'll want 3 templates — I'll call them 'news/index.html', 'news/_entry.html', and 'news/_extra.html'. (fyi... using an underscore before the template name is good practice as it prevents the template from being loaded directly; which would likely throw an error because no entry would be defined.)
You'll then want to create a custom route to the 'extra' page in settings, using the 'slug' token for one of the segments.

If your url looks like this: news/slug/extra (where 'slug' is the slug token)
Load this template: news/_extra.html

In the '_entry.html' template, you'll want to check your 'additional' field and create a link to your '/extra' page. Note: 'entry.url' should already include the 'news/slug' portion of the uri — we'll just be adding the '/extra' segment.
{% if entry.additional %}
    extra page
{% endif %}

In the '_extra.html' template, there should now be a 'slug' variable available to your entry.
{% set newsEntry = craft.entry.section('news').slug(slug) %}
{% set newsIndex = craft.entry.section('pages').slug('news') %}
{{ newsIndex.title }} — {{ newsEntry.title }}

Note: I don't know in what section your 'news' index page is. I just picked something at random — you'll need to change that to match your structure.

> **Comments:**
> **username_0**: To clarify your final note, the news index page in this example would belong to news. In relation to the actual template folder structure what I have is as follows: root = news.html then a folder called News with two templates inside called news_entry.html and news_extra.html – So in your example you use news/index.html, when it should be news.html – Did this match your understanding? Thank you for your answer and for pointing me in the right direction on this.  
> **username_1**: Yes. You can change the templates/paths to anything you want. I just used those as an example. I would still recommend placing an underscore in front of any templates that rely on an entry being defined however (i.e. '_news_entry.html' and '_news_extra.html').  
> **username_0**: I have renamed the last segment of Craft code as follows: {% set newsEntry = craft.entry.section('news').slug(slug) %} {% set newsIndex = craft.entry.section('news').slug('news') %} {{ newsIndex.title }} — {{ newsEntry.title }} - I am not sure where exactly to put this, and know that it is why {{ entry.newsExtra }} isn't loading in any information on the _extra.html page. The url which the user clicks on to see the extra page reads _extra.html - does this have to be the case, can it be made prettier without underscores while also taking your advice at the template side?  
> **username_1**: The {{ newIndex.title}} and {{ newsEntry.title}} are just an example to show you that you can access those entries as needed from your '_extras.html' template. Change to whatever you need. As far as the uri is concerned—you shouldn't have '_extra' in the uri, only in the route template definition. The uri should be 'news/{slug}/extra' where slug is the title of your news entry.  

---

