Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-01T16:05:35.793Z
Answers.LastActivityDate: 2014-07-01T16:05:35.793Z
Answers.UserDisplayName: Victor
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-01T15:56:45.980Z
Comments.Text: You can't save entries using the Model in a template. What would be the use case for this?
Comments.UserDisplayName: Bryan Redeagle
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-01T16:02:12.767Z
Comments.Text: Why didn't you use a custom "title" variable throughout your template instead of overriding the entry's title?
Comments.UserDisplayName: Simon Kuran
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-02T06:01:38.570Z
Comments.Text: 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
Comments.UserDisplayName: sneeky
Tags: <entries>
Title: Overwrite entry.title in template
ThreadText: # 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](http://twig.sensiolabs.org/doc/tags/set.html) can only be used on variables.
  
  But in your case `entry` is an object and `title` is it's [property](http://php.net/manual/en/language.oop5.properties.php).
  
  You could however create a work-around:
  
  ```twig
  {% set my_title = 'New' %}
  {{ my_title is defined ? my_title : entry.title }}
  
  ```
  
  If `my_title` is defined it will be outputted.
  
  
  ---
  
  