How do I set a specific entry in a template with "set" This won't work in a template:



{% set entry = craft.entries.id(43) %}&lt;h1&gt;Titel: {{ entry.title }}&lt;/h1&gt;


But this does:

{% for entry in craft.entries.id(43) %}&lt;h1&gt;Titel: {{ entry.title }}&lt;/h1&gt;{% endfor %}


Is it really necessary to use the for loop? I tried to use set because I'd like to over rule the entry variable for the whole template that I'm using if a specific url is visited

{% if craft.request.segment(2)=="openings-en-trainingstijden" %} {% set entry = craft.entries.id(43) %}{% endif %} {{ entry.title }} etc..


Another example this code:

{% for entry1 in craft.entries.id(43) %}Titel: {{ entry1.title }}{% endfor %}
{% set entry2 = craft.entries.id(43) %}Titel: {{ entry2.title }}


Results in:

Titel: Openings- en trainingstijden
Titel:
You need to add .first where you are setting the entry variable:

{% set entry = craft.entries.id(43).first %}

That way you can avoid doing a for loop.