<p>You will need to use <code>{% set practice = craft.entries.slug(slug).first() %}</code> to fetch the real <code>EntryModel</code>, and not just an <code>ElementCriteriaModel</code>.</p>

<p>I think the <code>relatedTo</code> criteria still works without it because that calls <code>.find()</code> implicitly when passed an <code>ElementCriteriaModel</code>, but that doesn't actually change what the <code>practice</code> variable references in the rest of the template.</p>

CC BY-SA 3.0
2017-02-09T10:11:24.000Z
2017-02-09T10:11:24.000Z
Mike Pepper
<p>I'm trying to create a template route that allows me to get all of the attorneys that I've related to a specified practice area. I can get the slug easily, as my route looks like this:</p>

<p><code>'attorneys/legal-services/(?P&lt;slug&gt;[^/]+)' =&gt; 'attorneys/legal-services'</code></p>

<p>And sure enough, when I go to <code>/attorneys/legal-services/construction-law</code>, I can access the <code>{{ slug }}</code> variable and grab <code>construction-law</code>.</p>

<p>The problem I'm having is that everything else in the object I request with <code>craft.entries.slug(slug)</code> ends up being <code>NULL</code>.</p>

<p>A simple code sample like this:</p>

<pre><code>{% extends '_layouts/two-column' %}
{% set practice = craft.entries.slug(slug) %}

{% block main %}
  &lt;main class="page-body"&gt;
    &lt;h1&gt;Attorneys&lt;/h1&gt;
    &lt;h2&gt;in {{ practice.title }}&lt;/h2&gt;
    {% for entry in craft.entries.section('people').relatedTo(practice) %}
      &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
    {% endfor %}
  &lt;/main&gt;
{% endblock %}
</code></pre>

<p>will output all the content I request in my <code>for</code> loop, but <code>practice.title</code> is left empty.</p>

<p>When I <code>dump</code> the contents of the <code>practice</code> object out, I see this:</p>

<pre><code>object(Craft\ElementCriteriaModel)[749]
  protected 'strictAttributes' =&gt; boolean false
  private '_elementType' =&gt; 
    object(Craft\EntryElementType)[742]
      protected 'componentType' =&gt; string 'ElementType' (length=11)
      private '_sourcesByContext' (Craft\BaseElementType) =&gt; null
      private '_classHandle' (Craft\BaseComponentType) =&gt; null
      public 'behaviors' =&gt; 
        array (size=0)
          empty
      private '_initialized' (CApplicationComponent) =&gt; boolean true
      private '_e' (CComponent) =&gt; null
      private '_m' (CComponent) =&gt; null
  private '_supportedFieldHandles' =&gt; null
  private '_matchedElements' =&gt; null
  private '_matchedElementsAtOffsets' =&gt; null
  private '_cachedIds' =&gt; null
  private '_cachedTotal' =&gt; null
  protected 'classSuffix' =&gt; string 'Model' (length=5)
  private '_classHandle' (Craft\BaseModel) =&gt; null
  private '_attributeConfigs' (Craft\BaseModel) =&gt; 
    array (size=45)
      'ancestorDist' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'ancestorOf' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'archived' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 1
          'default' =&gt; boolean false
          'required' =&gt; boolean true
          'column' =&gt; string 'tinyint' (length=7)
          'unsigned' =&gt; boolean true
          'type' =&gt; string 'bool' (length=4)
          'min' =&gt; int 0
          'max' =&gt; int 255
      'dateCreated' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'dateUpdated' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'descendantDist' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'descendantOf' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'fixedOrder' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 1
          'default' =&gt; boolean false
          'required' =&gt; boolean true
          'column' =&gt; string 'tinyint' (length=7)
          'unsigned' =&gt; boolean true
          'type' =&gt; string 'bool' (length=4)
          'min' =&gt; int 0
          'max' =&gt; int 255
      'id' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'indexBy' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'level' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'limit' =&gt; 
        array (size=9)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'default' =&gt; int 100
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'locale' =&gt; 
        array (size=2)
          'column' =&gt; string 'locale' (length=6)
          'type' =&gt; string 'locale' (length=6)
      'localeEnabled' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 1
          'default' =&gt; boolean true
          'required' =&gt; boolean true
          'column' =&gt; string 'tinyint' (length=7)
          'unsigned' =&gt; boolean true
          'type' =&gt; string 'bool' (length=4)
          'min' =&gt; int 0
          'max' =&gt; int 255
      'nextSiblingOf' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'offset' =&gt; 
        array (size=9)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'default' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'order' =&gt; 
        array (size=2)
          'default' =&gt; string 'lft, postDate desc' (length=18)
          'type' =&gt; string 'string' (length=6)
      'positionedAfter' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'positionedBefore' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'prevSiblingOf' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'relatedTo' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'ref' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'search' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'siblingOf' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'slug' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'status' =&gt; 
        array (size=2)
          'default' =&gt; string 'live' (length=4)
          'type' =&gt; string 'string' (length=6)
      'title' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'uri' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'with' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'childField' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'childOf' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'depth' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'parentField' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'parentOf' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'after' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'authorGroup' =&gt; 
        array (size=1)
          'type' =&gt; string 'string' (length=6)
      'authorGroupId' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'authorId' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'before' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'editable' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 1
          'default' =&gt; boolean false
          'required' =&gt; boolean true
          'column' =&gt; string 'tinyint' (length=7)
          'unsigned' =&gt; boolean true
          'type' =&gt; string 'bool' (length=4)
          'min' =&gt; int 0
          'max' =&gt; int 255
      'expiryDate' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'postDate' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'section' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
      'sectionId' =&gt; 
        array (size=8)
          'maxLength' =&gt; int 11
          'min' =&gt; int -2147483648
          'max' =&gt; int 2147483647
          'decimals' =&gt; int 0
          'type' =&gt; string 'number' (length=6)
          'unsigned' =&gt; boolean false
          'length' =&gt; int 10
          'column' =&gt; string 'integer' (length=7)
      'type' =&gt; 
        array (size=3)
          'model' =&gt; null
          'column' =&gt; string 'text' (length=4)
          'type' =&gt; string 'mixed' (length=5)
  private '_attributes' (Craft\BaseModel) =&gt; 
    array (size=9)
      'archived' =&gt; boolean false
      'fixedOrder' =&gt; boolean false
      'limit' =&gt; int 100
      'localeEnabled' =&gt; boolean true
      'offset' =&gt; int 0
      'order' =&gt; string 'lft, postDate desc' (length=18)
      'status' =&gt; string 'live' (length=4)
      'editable' =&gt; boolean false
      'slug' =&gt; string 'construction-law' (length=16)
  private '_extraAttributeNames' (Craft\BaseModel) =&gt; 
    array (size=0)
      empty
  private '_errors' (CModel) =&gt; 
    array (size=0)
      empty
  private '_validators' (CModel) =&gt; null
  private '_scenario' (CModel) =&gt; string '' (length=0)
  private '_e' (CComponent) =&gt; null
  private '_m' (CComponent) =&gt; null
</code></pre>

<p>As a result, I'm getting</p>

<pre><code>&lt;h1&gt;Attorneys&lt;/h1&gt;
&lt;h2&gt;in &lt;/h2&gt;
</code></pre>

<p>even though I'm expecting to see the title of the practice area.</p>

<routing><slug>
Getting only slug in otherwise null object on routed template
# Getting only slug in otherwise null object on routed template

(Asked by: username_0 on 2017-02-09)

I'm trying to create a template route that allows me to get all of the attorneys that I've related to a specified practice area. I can get the slug easily, as my route looks like this:
'attorneys/legal-services/(?P[^/]+)' => 'attorneys/legal-services'
And sure enough, when I go to /attorneys/legal-services/construction-law, I can access the {{ slug }} variable and grab construction-law.
The problem I'm having is that everything else in the object I request with craft.entries.slug(slug) ends up being NULL.
A simple code sample like this:
{% extends '_layouts/two-column' %}
{% set practice = craft.entries.slug(slug) %}

{% block main %}
  
    Attorneys
    in {{ practice.title }}
    {% for entry in craft.entries.section('people').relatedTo(practice) %}
      {{ entry.title }}
    {% endfor %}
  
{% endblock %}

will output all the content I request in my for loop, but practice.title is left empty.
When I dump the contents of the practice object out, I see this:
object(Craft\ElementCriteriaModel)[749]
  protected 'strictAttributes' => boolean false
  private '_elementType' => 
    object(Craft\EntryElementType)[742]
      protected 'componentType' => string 'ElementType' (length=11)
      private '_sourcesByContext' (Craft\BaseElementType) => null
      private '_classHandle' (Craft\BaseComponentType) => null
      public 'behaviors' => 
        array (size=0)
          empty
      private '_initialized' (CApplicationComponent) => boolean true
      private '_e' (CComponent) => null
      private '_m' (CComponent) => null
  private '_supportedFieldHandles' => null
  private '_matchedElements' => null
  private '_matchedElementsAtOffsets' => null
  private '_cachedIds' => null
  private '_cachedTotal' => null
  protected 'classSuffix' => string 'Model' (length=5)
  private '_classHandle' (Craft\BaseModel) => null
  private '_attributeConfigs' (Craft\BaseModel) => 
    array (size=45)
      'ancestorDist' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'ancestorOf' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'archived' => 
        array (size=8)
          'maxLength' => int 1
          'default' => boolean false
          'required' => boolean true
          'column' => string 'tinyint' (length=7)
          'unsigned' => boolean true
          'type' => string 'bool' (length=4)
          'min' => int 0
          'max' => int 255
      'dateCreated' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'dateUpdated' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'descendantDist' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'descendantOf' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'fixedOrder' => 
        array (size=8)
          'maxLength' => int 1
          'default' => boolean false
          'required' => boolean true
          'column' => string 'tinyint' (length=7)
          'unsigned' => boolean true
          'type' => string 'bool' (length=4)
          'min' => int 0
          'max' => int 255
      'id' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'indexBy' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'level' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'limit' => 
        array (size=9)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'default' => int 100
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'locale' => 
        array (size=2)
          'column' => string 'locale' (length=6)
          'type' => string 'locale' (length=6)
      'localeEnabled' => 
        array (size=8)
          'maxLength' => int 1
          'default' => boolean true
          'required' => boolean true
          'column' => string 'tinyint' (length=7)
          'unsigned' => boolean true
          'type' => string 'bool' (length=4)
          'min' => int 0
          'max' => int 255
      'nextSiblingOf' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'offset' => 
        array (size=9)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'default' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'order' => 
        array (size=2)
          'default' => string 'lft, postDate desc' (length=18)
          'type' => string 'string' (length=6)
      'positionedAfter' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'positionedBefore' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'prevSiblingOf' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'relatedTo' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'ref' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'search' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'siblingOf' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'slug' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'status' => 
        array (size=2)
          'default' => string 'live' (length=4)
          'type' => string 'string' (length=6)
      'title' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'uri' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'with' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'childField' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'childOf' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'depth' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'parentField' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'parentOf' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'after' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'authorGroup' => 
        array (size=1)
          'type' => string 'string' (length=6)
      'authorGroupId' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'authorId' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'before' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'editable' => 
        array (size=8)
          'maxLength' => int 1
          'default' => boolean false
          'required' => boolean true
          'column' => string 'tinyint' (length=7)
          'unsigned' => boolean true
          'type' => string 'bool' (length=4)
          'min' => int 0
          'max' => int 255
      'expiryDate' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'postDate' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'section' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
      'sectionId' => 
        array (size=8)
          'maxLength' => int 11
          'min' => int -2147483648
          'max' => int 2147483647
          'decimals' => int 0
          'type' => string 'number' (length=6)
          'unsigned' => boolean false
          'length' => int 10
          'column' => string 'integer' (length=7)
      'type' => 
        array (size=3)
          'model' => null
          'column' => string 'text' (length=4)
          'type' => string 'mixed' (length=5)
  private '_attributes' (Craft\BaseModel) => 
    array (size=9)
      'archived' => boolean false
      'fixedOrder' => boolean false
      'limit' => int 100
      'localeEnabled' => boolean true
      'offset' => int 0
      'order' => string 'lft, postDate desc' (length=18)
      'status' => string 'live' (length=4)
      'editable' => boolean false
      'slug' => string 'construction-law' (length=16)
  private '_extraAttributeNames' (Craft\BaseModel) => 
    array (size=0)
      empty
  private '_errors' (CModel) => 
    array (size=0)
      empty
  private '_validators' (CModel) => null
  private '_scenario' (CModel) => string '' (length=0)
  private '_e' (CComponent) => null
  private '_m' (CComponent) => null

As a result, I'm getting
Attorneys
in 

even though I'm expecting to see the title of the practice area.

**Tags:** routing, slug


---

## 1 answers

### Answer by username_1 on 2017-02-09. Score: 4 | Accepted answer

You will need to use `{% set practice = craft.entries.slug(slug).first() %}` to fetch the real `EntryModel`, and not just an `ElementCriteriaModel`.

I think the `relatedTo` criteria still works without it because that calls `.find()` implicitly when passed an `ElementCriteriaModel`, but that doesn't actually change what the `practice` variable references in the rest of the template.


---

