<p><code>craft.entries</code> now returns an <a href="https://docs.craftcms.com/v3/dev/element-queries/" rel="nofollow noreferrer">ElementQuery</a>. When you add the <code>.all()</code> you're telling Craft to execute the query, which returns an <code>array</code> of Elements.</p>

<p>That means that <code>solutions</code> is now a simple array, and won't have methods like <code>.limit(1)</code> that can be executed on it. It looks like you just want to use the first item in the <code>solutions</code> array, so try changing this:</p>

<pre><code>      {% nav solution in solutions.limit(1) %}
           &lt;a class="nav-link" href="{{ solution.url }}"&gt;solutions&lt;span class="sr-only"&gt;(current)&lt;/span&gt; &lt;i class="icon-downarrow"&gt;&lt;/i&gt; &lt;/a&gt;
      {% endnav %}
</code></pre>

<p>To this:</p>

<pre><code>       &lt;a class="nav-link" href="{{ solutions[0].url }}"&gt;solutions&lt;span class="sr-only"&gt;(current)&lt;/span&gt; &lt;i class="icon-downarrow"&gt;&lt;/i&gt; &lt;/a&gt;
</code></pre>

<p>More here: <a href="https://docs.craftcms.com/v3/dev/tags/nav.html" rel="nofollow noreferrer">{% nav %} Tags</a></p>

CC BY-SA 4.0
2018-11-08T02:11:35.570Z
2018-11-08T02:11:35.570Z
andrew.welch
<p>I recently upgraded a site from Craft 2 to Craft 3, so I'm trying to figure out what was deprecated and caused this error. </p>

<p>At the top of the page I have this</p>

<pre><code>{% set solutions = craft.entries.section('solutions').level(1).all() %}
</code></pre>

<p>And I'm trying to invoke a dropdown menu like so </p>

<pre><code>&lt;li class="nav-item {% if craft.request.segment(1) == 'solutions' %}active{% endif %}"&gt;
    {% nav solution in solutions.limit(1) %}
        &lt;a class="nav-link" href="{{ solution.url }}"&gt;solutions&lt;span class="sr-only"&gt;(current)&lt;/span&gt; &lt;i class="icon-downarrow"&gt;&lt;/i&gt; &lt;/a&gt;
    {% endnav %}
    &lt;ul class="submenu"&gt;
        {% nav solution in solutions %}
            &lt;li&gt;
                &lt;a href="{{ solution.url }}"&gt;{{ solution.title }}&lt;/a&gt;
            &lt;/li&gt;
        {% endnav %}
    &lt;/ul&gt;
&lt;/li&gt;
</code></pre>

<p>Before I didn't have <code>.all()</code> at the end, but only the first menuitem was showing up.
When I added <code>.all()</code> in, I get the error <code>"Impossible to invoke a method ("limit") on an array."</code></p>

<craft3><craft2>
Impossible to invoke a method ("limit") on an array
# Impossible to invoke a method ("limit") on an array

(Asked by: username_0 on 2018-11-08)

I recently upgraded a site from Craft 2 to Craft 3, so I'm trying to figure out what was deprecated and caused this error. 
At the top of the page I have this
{% set solutions = craft.entries.section('solutions').level(1).all() %}

And I'm trying to invoke a dropdown menu like so 

    {% nav solution in solutions.limit(1) %}
        solutions(current)  
    {% endnav %}
    
        {% nav solution in solutions %}
            
                {{ solution.title }}
            
        {% endnav %}
    


Before I didn't have .all() at the end, but only the first menuitem was showing up.
When I added .all() in, I get the error "Impossible to invoke a method ("limit") on an array."

**Tags:** craft3, craft2

---

## 1 answers

### Answer by username_1 on 2018-11-08. Score: 2 | Accepted answer

craft.entries now returns an ElementQuery. When you add the .all() you're telling Craft to execute the query, which returns an array of Elements.
That means that solutions is now a simple array, and won't have methods like .limit(1) that can be executed on it. It looks like you just want to use the first item in the solutions array, so try changing this:
      {% nav solution in solutions.limit(1) %}
           solutions(current)  
      {% endnav %}

To this:
       solutions(current)  

More here: {% nav %} Tags


---

