Answers.Body: <p>I figured this one out right after I posted it. </p>
  
  <pre><code>{% set blogTag = craft.tags({ tag: tag, group: 'blogTags' }).first() %}
  </code></pre>
  
  <p>One mistake was searching for it with "name" instead of "tag". </p>
  
  <p>The other mistake was that I needed to call first() to get the TagModel. Otherwise, craft.tags() just returns an ElementCriteriaModel.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-12T17:30:26.640Z
Answers.LastActivityDate: 2014-08-12T17:58:45.277Z
Answers.LastEditDate: 2014-08-12T17:58:45.277Z
Answers.UserDisplayName: Jason D
Body: <p>I have a route that matches:</p>
  
  <pre><code>/blog/tagged/{tag}
  </code></pre>
  
  <p>And in my template I would like to pull up all blogs that are related to the tag:</p>
  
  <pre><code>{% if tag is defined %}
      {% set blogTag = craft.tags({ name: tag, group: 'blogTags' }) %}
      {% set filter = filter|merge({ relatedTo: blogTag }) %}
  {% endif %}
  
  {% for entry in craft.entries(filter).find() %}
  </code></pre>
  
  <p>But this doesn't work since craft.tags() gives me an ElementCriteriaModel, but I need a TagModel to work with relatedTo(). </p>
  
  <p>I can't figure out how to get the TagModel here.</p>
  
Tags: <tags>
Title: How do you get ahold of a TagModel in a template?
ThreadText: # How do you get ahold of a TagModel in a template?
  
  (Asked by: username_0 on 2014-08-12)
  
  I have a route that matches:
  
  ```
  /blog/tagged/{tag}
  
  ```
  
  And in my template I would like to pull up all blogs that are related to the tag:
  
  ```
  {% if tag is defined %}
      {% set blogTag = craft.tags({ name: tag, group: 'blogTags' }) %}
      {% set filter = filter|merge({ relatedTo: blogTag }) %}
  {% endif %}
  
  {% for entry in craft.entries(filter).find() %}
  
  ```
  
  But this doesn't work since craft.tags() gives me an ElementCriteriaModel, but I need a TagModel to work with relatedTo().
  
  I can't figure out how to get the TagModel here.
  
  **Tags:** tags
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2014-08-12. Score: 2
  
  I figured this one out right after I posted it.
  
  ```
  {% set blogTag = craft.tags({ tag: tag, group: 'blogTags' }).first() %}
  
  ```
  
  One mistake was searching for it with "name" instead of "tag".
  
  The other mistake was that I needed to call first() to get the TagModel. Otherwise, craft.tags() just returns an ElementCriteriaModel.
  
  
  ---
  
  