<p>Having an issue searching a Matrix field for a block with a certain value and storing the entire block in a variable. Right now it only seems to be storing the <code>location</code> value. The <code>navigations</code> field is a Super Table.  </p>

<pre><code>{## looping through matrix blocks works ##}
{% for block in siteNav.navigations %}

    {{ block.location }}

    {% for row in block.navLinks %}
        {{ row.label }}&lt;br&gt;
    {% endfor %}
{% endfor %}

{## set variable via search matrix block only selects location field ##}
{% set utilityNav = siteNav.navigations.location('utility').limit(1) %}

{{ utilityNav.location }}

{% for row in utilityNav.navLinks %}
  {{ row.label }}&lt;br&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-10-11T21:39:27.687Z
Having a hard time following this for some reason. I'm guessing your top example works, but the bottom doesn't?  What's the `location` field? Are you getting an error when you try to loop through `utilityNav.navLinks`?
Brad Bell
CC BY-SA 3.0
2016-10-12T11:25:38.227Z
Sorry about that. You're correct–the top example works. The bottom example only parses the `location` text field in the matrix block. I'm not able to loop through `utilityNav.navLinks` super table field– no errors either.
Siebird
CC BY-SA 3.0
2016-10-12T11:33:13.403Z
*correction. `location` field is a dropdown
Siebird
<matrix><plugin-supertable>
Storing a Matrix block data in a variable
# Storing a Matrix block data in a variable

(Asked by: username_0 on 2016-10-11)

Having an issue searching a Matrix field for a block with a certain value and storing the entire block in a variable. Right now it only seems to be storing the location value. The navigations field is a Super Table.  
{## looping through matrix blocks works ##}
{% for block in siteNav.navigations %}

    {{ block.location }}

    {% for row in block.navLinks %}
        {{ row.label }}
    {% endfor %}
{% endfor %}

{## set variable via search matrix block only selects location field ##}
{% set utilityNav = siteNav.navigations.location('utility').limit(1) %}

{{ utilityNav.location }}

{% for row in utilityNav.navLinks %}
  {{ row.label }}
{% endfor %}

**Tags:** matrix, plugin-supertable

> **Comments:**
> **username_1**: Having a hard time following this for some reason. I'm guessing your top example works, but the bottom doesn't?  What's the `location` field? Are you getting an error when you try to loop through `utilityNav.navLinks`?  
> **username_0**: Sorry about that. You're correct–the top example works. The bottom example only parses the `location` text field in the matrix block. I'm not able to loop through `utilityNav.navLinks` super table field– no errors either.  
> **username_0**: *correction. `location` field is a dropdown  

---

## 0 answers

