<p>I have some routes i want to use like
&quot;/my-url/locationZ&quot;
&quot;/my-url/locationX&quot;</p>
<p>This loads a template /dynamic.twig</p>
<p>In the template dynamic I am trying to get the content from an existing entry like:</p>
<pre><code>{% set entry = craft.entries()
       .id('2268')
   %}
</code></pre>
<p>But the entry is always null.</p>
<p>How can I pull the entry into my dynamic.twig template when the route is used?</p>

CC BY-SA 4.0
2021-03-31T18:31:00.283Z
Are you sure the entry exists in your current language?
You should also always query an entry with `.one()` or `.all()` at the end, because not using those is deprecated as of craft 3.
Joorren
CC BY-SA 4.0
2021-04-01T10:12:42.773Z
Doh! Needed .one()
joomkit
CC BY-SA 4.0
2021-04-01T23:04:13.693Z
Can you add that as an official answer?
Brad Bell
<routes>
Setting an entry in a dynamic route template
# Setting an entry in a dynamic route template

(Asked by: username_0 on 2021-03-31)

I have some routes i want to use like
"/my-url/locationZ"
"/my-url/locationX"
This loads a template /dynamic.twig
In the template dynamic I am trying to get the content from an existing entry like:
{% set entry = craft.entries()
       .id('2268')
   %}

But the entry is always null.
How can I pull the entry into my dynamic.twig template when the route is used?

**Tags:** routes

> **Comments:**
> **username_1**: Are you sure the entry exists in your current language? You should also always query an entry with `.one()` or `.all()` at the end, because not using those is deprecated as of craft 3.  
> **username_0**: Doh! Needed .one()  
> **username_2**: Can you add that as an official answer?  

---

## 0 answers

