<p>When you use the single brace tag syntax within your URL Format field:</p>

<pre><code>{category.first().title}
</code></pre>

<p>that’s actually a shortcut for this:</p>

<pre><code>{{ object.category.first().title }}
</code></pre>

<p>So, <code>object</code> is the actual variable name that you can use to refer to your entry, when you want to use the normal Twig tags <code>{{ ... }}</code> and <code>{% ... %}</code>.</p>

<pre><code>{% for categoryList in object.category %}{{ categoryList.title }}{% if not loop.last %}/{% endif %}{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-09-11T17:37:42.087Z
It works of course!! Awesome and good to know.
Alan Miller
CC BY-SA 3.0
2014-09-11T17:29:52.430Z
2014-09-11T17:29:52.430Z
Brandon Kelly
<p>I think you could also use Twig's <a href="http://twig.sensiolabs.org/doc/filters/join.html" rel="nofollow">join filter</a> instead of the for loop:</p>

<pre><code>{{ object.category | join('/') }}
</code></pre>

CC BY-SA 3.0
2014-09-11T18:47:59.670Z
2014-09-11T18:47:59.670Z
Jamie Pittock
<p>I have a single category field (named category) in my section and I am looking to use the auto-generated title to keep these entries titled consistently. I have had success outputting the first category selection into the entry field but I can't seem to grab multiple selections. I have tried a for loop and I can of course getting working on a template but I am thinking the syntax must be different for the auto generated title field.</p>

<p>Here is an example of the tree I am working with.</p>

<ul>
<li>Category One
<ul>
<li>Sub Cat One</li>
<li>Sub Cat Two</li>
</ul></li>
</ul>

<p>In a example entry I will have Sub Cat One selected and of course Category One since it is an ancestor of the Sub Cat One. I would like to output something like (Category One / Sub Cat One) in the entry title but I either get no results or just the first one. I have tried the following code:</p>

<pre><code>{% for categoryList in category %}{{categoryList.title}}{% if loop.index &lt; loop.length %}/{% endif %}{% endfor %}
</code></pre>

<p>and</p>

<pre><code>{category.first().title}
</code></pre>

<p>Which of course contains only the first selected category title.</p>

<p>How do you output more than one category selection in an entry title field?</p>

<p>Thanks!</p>

<titles><auto-generate><post>
Multiple category output in auto generated entry title
# Multiple category output in auto generated entry title

(Asked by: username_0 on 2014-09-11)

I have a single category field (named category) in my section and I am looking to use the auto-generated title to keep these entries titled consistently. I have had success outputting the first category selection into the entry field but I can't seem to grab multiple selections. I have tried a for loop and I can of course getting working on a template but I am thinking the syntax must be different for the auto generated title field.
Here is an example of the tree I am working with.

Category One

Sub Cat One
Sub Cat Two


In a example entry I will have Sub Cat One selected and of course Category One since it is an ancestor of the Sub Cat One. I would like to output something like (Category One / Sub Cat One) in the entry title but I either get no results or just the first one. I have tried the following code:
{% for categoryList in category %}{{categoryList.title}}{% if loop.index < loop.length %}/{% endif %}{% endfor %}

and
{category.first().title}

Which of course contains only the first selected category title.
How do you output more than one category selection in an entry title field?
Thanks!

**Tags:** titles, auto-generate, post

---

## 2 answers

### Answer by username_1 on 2014-09-11. Score: 2 | Accepted answer

When you use the single brace tag syntax within your URL Format field:
{category.first().title}

that’s actually a shortcut for this:
{{ object.category.first().title }}

So, object is the actual variable name that you can use to refer to your entry, when you want to use the normal Twig tags {{ ... }} and {% ... %}.
{% for categoryList in object.category %}{{ categoryList.title }}{% if not loop.last %}/{% endif %}{% endfor %}

> **Comments:**
> **username_0**: It works of course!! Awesome and good to know.  

---

### Answer by username_2 on 2014-09-11. Score: 3

I think you could also use Twig's join filter instead of the for loop:
{{ object.category | join('/') }}


---

