<p>It's my understanding that <a href="http://twig.sensiolabs.org/doc/tags/set.html">Twig's set tag</a> can only be used on variables.</p>

<p>But in your case <code>entry</code> is an object and <code>title</code> is it's <a href="http://php.net/manual/en/language.oop5.properties.php">property</a>.</p>

<p>You could however create a work-around:</p>

<pre class="lang-twig prettyprint-override"><code>{% set my_title = 'New' %}
{{ my_title is defined ? my_title : entry.title }}
</code></pre>

<p>If <code>my_title</code> is defined it will be outputted.</p>

CC BY-SA 3.0
2014-07-01T16:05:35.793Z
2014-07-01T16:05:35.793Z
Victor
<p>Does anybody know if it is possible to overwrite entry.title in a template?</p>

<p>The following 2 options causes errors:</p>

<pre><code>{% set entry.title = 'value' %}
{% set entry['title'] = 'value' %}
</code></pre>

CC BY-SA 3.0
2014-07-01T15:56:45.980Z
You can't save entries using the Model in a template. What would be the use case for this?
Bryan Redeagle
CC BY-SA 3.0
2014-07-01T16:02:12.767Z
Why didn't you use a custom "title" variable throughout your template instead of overriding the entry's title?
Simon Kuran
CC BY-SA 3.0
2014-07-02T06:01:38.570Z
Thank you for your answers. The use case is: there is a page (match detail for a sportsclub) which isn't an entry, but with a route I use a template. The data comes from xml. In the template I get the entry data from the 'parent' entry. And I wanted to overwrite the entry.title with the Match title. 
But I founded an other solution for this. Thank you anyway
sneeky
<entries>
Overwrite entry.title in template
# Overwrite entry.title in template

(Asked by: username_0 on 2014-07-01)

Does anybody know if it is possible to overwrite entry.title in a template?
The following 2 options causes errors:
{% set entry.title = 'value' %}
{% set entry['title'] = 'value' %}

**Tags:** entries
> **Comments:**
> **username_1**: You can't save entries using the Model in a template. What would be the use case for this?  
> **username_2**: Why didn't you use a custom "title" variable throughout your template instead of overriding the entry's title?  
> **username_0**: Thank you for your answers. The use case is: there is a page (match detail for a sportsclub) which isn't an entry, but with a route I use a template. The data comes from xml. In the template I get the entry data from the 'parent' entry. And I wanted to overwrite the entry.title with the Match title.  But I founded an other solution for this. Thank you anyway  

---

## 1 answers

### Answer by username_3 on 2014-07-01. Score: 5

It's my understanding that Twig's set tag can only be used on variables.
But in your case entry is an object and title is it's property.
You could however create a work-around:
{% set my_title = 'New' %}
{{ my_title is defined ? my_title : entry.title }}

If my_title is defined it will be outputted.


---

