How to create an auxiliary page with sub url? 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.
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 %}
    &lt;a href="{{ entry.url ~ '/extra' }}"&gt;extra page&lt;/a&gt;
{% 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.