1

I'm working on a website that was developed by someone else before me, I added a new section and template, I uploaded all my files, created my new section and field and created my first entry everything was looking good, I decided to add a second entry to ensure that everything is working, but when I preview the entry Craft is showing both entries on one page instead of creating separate page for the entries. Please, can someone tell what is the reason for that I'm new using Craft below is the code that I wrote for the new template?

{% extends "layout/_layout" %}

{% block breadcrumbs %}
    {% include 'includes/_Breadcrumbs' with { 'currentTitle' : entry.title } %}
{% endblock %}

{% block content %}

    {% for entry in craft.entries.section('newContent') %}

        {% include 'includes/_pageTitle' %}

        {# Top Content Section 1 #}
        <div class="ContentBox section-one">
            <div class="Container">
                <div class="flex">
                    <div class="flex-content">
                        {% for block in entry.Headline %}
                            <h2 class="content-title Content-header">
                                {{ block.headline }}
                            </h2>
                            {% if block.subHeadline %}
                                <h4 class="content-subtitle subHeader">{{ block.subHeadline }}</h4>
                            {% endif %}
                        {% endfor %}
                        {% if entry.leadInText %}
                            {{ entry.leadInText }}
                        {% endif %}
                    </div>
                    <!-- Sidebar section -->
                    <div class="aside sidebar">
                        {% include 'includes/_asideBox' %}
                    </div>
                    <!-- End sidebar section -->
                </div>
            </div>
        </div>

        {# Start Sections 2 - 5 #}
        {% for block in entry.newContentMatrix %}
            {% switch block.type %}

                {% case "twoColumnSection" %}
                    {% include 'includes/_sectionTwo' %}

                {# Section 3 #}
                {% case "paragraphSection" %}
                    {% include 'includes/_paragraphSection' %}

                {# Double list Section #}
                {% case "listSection" %}
                    {% include 'includes/_listSection' %}

                {# Section 4 #}
                {% case "miniFormSection" %}
                    {% include 'includes/_miniFormSection' %}

                {# Call to action Banner #}
                {% case "callToActionBanner" %}
                    {% include 'includes/_callToAction' %}

            {% endswitch %}
        {% endfor %}

    {% endfor %}

    {% includeJsFile "/public/ui/js/accodion-menu.js" %}
    {% includeJsFile "/public/ui/js/SideNavTrigger.Js" %}

{% endblock %}
1
  • Hard for me to tell what's going on from the example code. By default if you don't specify an orderBy parameter on your query, Craft will go with the entries postDate. Can you edit the question to share what exactly you're seeing and what you expect the behavior to be?
    – Brad Bell
    Commented May 18, 2018 at 21:19

1 Answer 1

1

Craft will inject the current entry by default in your template. All you have to do is to remove this loop

{% for entry in craft.entries.section('newContent') %} 

And you are fine.

Currently you are fetching all entries within your section. If you don't want to display them all but only the current you should not do that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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