1

I'm posting a lot of newbie questions today, hope that's ok. It will get better!

I would like to add a channel (list/detail) to a structure page.

Home > Pages > List Page

I'm sure I'm looking at it the wrong way. I'm used to create this list page as a "real" page in a structure in another CMS (TYPO3) and add the "channel" content as a plugin.

Maybe in Craft, you don't do that (create the channels "containing page") at all? But then again, how do you tell the main site navigation it should link to the channel?

  • Ah I see... I can make a select box (for example), where you can pick the functionality ("Plugin") and depending on that (instead of interpreting the URL) display the entry list! – Urs Aug 24 '18 at 20:57
  • Can you add your solution as an official answer in case it ends up helping someone in the future? – Brad Bell Aug 24 '18 at 22:48
1

I finally found out craft allows multiple entry types. So a regular "structure" page can be of type "page" or, eg, of type "listpage".

I created the second entry type and gave it a field function instead of the content.

In my regular structure page, I did the following:

{# switch between content pages and list pages; if list page, display selected list #}

{% if entry.type == 'listpage' %}
    <article class="content-element">
        <h1 class="heading-content-main">{{entry.title}}</h1>
            {% switch entry.function %}
            {% case "interviews" %}
                {% include "interviews/_list.html" %}
            {% case "researchprojects" %}
                {% include "researchprojects/_list.html" %}
            {% case "seminars" %}
                {% include "seminars/_list.html" %}
            {% endswitch %}
    </article>
{% else %}
    <article class="content-element">
        <h1 class="heading-content-main">{{entry.title}}</h1>
        <div class="rte-content w-richtext">
            {{entry.richtext}}
        </div>
    </article>
{% endif %}

Great!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.