3

I am new at Craft CMS so have patience with me (and my English).

I don't know if I am doing this right, but I have a link (URL) from my index.html, and I want to display the specific content on the _entry.html.

Index.html

{% for entry in craft.entries.section('news') %}
    <h3><a href="{{ entry.url }}">{{ entry.title }}</a></h3>
{% endfor %}

And when I click on that link I want only to display the content related to that entry.url.

If I click the link now, all my entries will show in _entry.html.

_entry.html

{% for entry in craft.entries.section('news').type('news') %}
    <h1>{{ entry.title }}</h1>
{% endfor %}

I just want to show the specific content for that section.


Update:

I tested this and it worked:

{% for entry in craft.entries.section('news').type('news').slug(craft.request.getSegment(2)) %}

But I don't know why?

3

Just use {{ entry.title }} on your dynamic _entry template to output that specific title. You were looping through all the news entries again on the dynamic _entry template and listing each one. Any other custom fields on that page/section can be accessed simply by {{ entry.myCustomFieldName }}.

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.