<p>I had a stupid typo in my path, where instead of the <code>date</code> filter, I'd typed <code>dateCreated</code>:</p>

<pre><code>/our-journal/{ entry.dateCreated|date('Y-m') ?: now|dateCreated('Y-m') }/{ slug }
</code></pre>

<p>Should be:</p>

<pre><code>/our-journal/{ entry.dateCreated|date('Y-m') ?: now|date('Y-m') }/{ slug }
</code></pre>

<p>Which, with what I learnt about fallbacks (see below), can be shortened to:</p>

<pre><code>/our-journal/{ entry.dateCreated|date('Y-m') }/{ slug }
</code></pre>

<p>And if you're doing this within a matrix field, the entry is referred to by <code>owner</code> - so you'd need:</p>

<pre><code>/our-journal/{ owner.dateCreated|date('Y-m') }/{ owner.slug }/
</code></pre>

<p><strong>Fallbacks</strong></p>

<p>I also found that I didn't need to provide fallbacks for entry tags - I'd thought that I'd need to provide a fallback for when a new entry hasn't yet been saved (to stop it falling over on e.g. <code>dateCreated</code>).</p>

<p>It appears that Craft is clever enough to hold the image in some temporary store, then move it into the intended folder when the article is first saved.</p>

CC BY-SA 3.0
2017-11-02T10:07:10.873Z
2017-11-02T10:43:55.973Z
2017-11-02T10:43:55.973Z
Adam Hopkinson
<p>I'm trying to set a default asset folder for a field, as per the Craft docs on <a href="https://craftcms.com/docs/assets-fields#dynamic-subfolder-paths" rel="nofollow noreferrer">Dynamic Subfolder Paths</a>.</p>

<p>I'm trying to set the asset path for each blog article to be <code>/our-journal/{date}/{slug}</code>, where date is the creation date of the article, falling back to today's date otherwise.</p>

<pre><code>/our-journal/{ entry.dateCreated|date('Y-m') ?: now|dateCreated('Y-m') }/{ slug }
</code></pre>

<p>I'm getting an internal server error:</p>

<blockquote>
  <p>Could not resolve the subpath “our-journal/{ entry.dateCreated|date('Y-m') ?: now|dateCreated('Y-m') }/{ slug }”.</p>
</blockquote>

<p>I've tried using both single and double braces around the variables, as the docs are a bit ambiguous.</p>

CC BY-SA 3.0
2017-11-01T18:45:12.770Z
Is Asset field inside of a Matrix field?
Brad Bell
CC BY-SA 3.0
2017-11-02T09:06:22.497Z
I've got the default path on two fields - one on the entry and one in a matrix field on the same entry type. As far as I can see, it's the field directly on the entry that is causing the issue (probably both are, but that one is hitting validation first).
Adam Hopkinson
CC BY-SA 3.0
2017-11-02T10:07:53.373Z
Thanks for your help @BradBell, I found a stupid typo. Also found something interesting about how Craft handles asset uploads on unsaved entries - see my answer below.
Adam Hopkinson
<assets><field><tags>
Trying to set a default asset folder using Craft tags
# Trying to set a default asset folder using Craft tags

(Asked by: username_0 on 2017-11-01)

I'm trying to set a default asset folder for a field, as per the Craft docs on Dynamic Subfolder Paths.
I'm trying to set the asset path for each blog article to be /our-journal/{date}/{slug}, where date is the creation date of the article, falling back to today's date otherwise.
/our-journal/{ entry.dateCreated|date('Y-m') ?: now|dateCreated('Y-m') }/{ slug }

I'm getting an internal server error:

Could not resolve the subpath “our-journal/{ entry.dateCreated|date('Y-m') ?: now|dateCreated('Y-m') }/{ slug }”.

I've tried using both single and double braces around the variables, as the docs are a bit ambiguous.

**Tags:** assets, field, tags

> **Comments:**
> **username_1**: Is Asset field inside of a Matrix field?  
> **username_0**: I've got the default path on two fields - one on the entry and one in a matrix field on the same entry type. As far as I can see, it's the field directly on the entry that is causing the issue (probably both are, but that one is hitting validation first).  
> **username_0**: Thanks for your help @BradBell, I found a stupid typo. Also found something interesting about how Craft handles asset uploads on unsaved entries - see my answer below.  

---

## 1 answers

### Answer by username_0 on 2017-11-02. Score: 1

I had a stupid typo in my path, where instead of the date filter, I'd typed dateCreated:
/our-journal/{ entry.dateCreated|date('Y-m') ?: now|dateCreated('Y-m') }/{ slug }

Should be:
/our-journal/{ entry.dateCreated|date('Y-m') ?: now|date('Y-m') }/{ slug }

Which, with what I learnt about fallbacks (see below), can be shortened to:
/our-journal/{ entry.dateCreated|date('Y-m') }/{ slug }

And if you're doing this within a matrix field, the entry is referred to by owner - so you'd need:
/our-journal/{ owner.dateCreated|date('Y-m') }/{ owner.slug }/

Fallbacks
I also found that I didn't need to provide fallbacks for entry tags - I'd thought that I'd need to provide a fallback for when a new entry hasn't yet been saved (to stop it falling over on e.g. dateCreated).
It appears that Craft is clever enough to hold the image in some temporary store, then move it into the intended folder when the article is first saved.


---

