<p>According to the <a href="https://github.com/fruitstudios/Icons/#usage" rel="nofollow">docs for the Icons plugin</a>, <code>icon</code> is actually an <strong>object</strong>. Try this instead...</p>

<pre><code>&lt;i class="fa {{ block.icon.class }}"&gt;&lt;/i&gt;
</code></pre>

<p>In both scenarios, I'd take another look at your rendered HTML... your first example may actually be rendering the word <code>Array</code> instead of the class name that you are looking for. You can also leave off the leading <code>fa-</code>, since that will be automatically included in the class name.</p>

<p>Where you have called <code>icon</code> in both examples, you're simply referring to <em>the field itself</em>. You actually want to be referring to the <em>values of the field</em>.</p>

<p>To output the HTML you're looking for, either of these two options will work:</p>

<ol>
<li><code>{{ block.icon.icon }}</code></li>
<li><code>&lt;i class="fa {{ block.icon.class }}"&gt;&lt;/i&gt;</code></li>
</ol>

<p>And for your non-matrix example, just replace <code>block</code> with <code>point</code>.</p>

CC BY-SA 3.0
2014-08-12T06:32:44.310Z
This worked, any idea why it worked without that in one instance and required it in another?
Christopher Healey
CC BY-SA 3.0
2014-08-12T06:34:37.237Z
Are you sure the `point` instance was generating the right HTML code? (Was the icon actually showing up?) According to the plugin docs, that code snippet shouldn't have worked.
Lindsey D
CC BY-SA 3.0
2014-08-12T08:03:55.097Z
Yep, showed up and worked EXACTLY as intended.
Christopher Healey
CC BY-SA 3.0
2014-08-11T16:03:31.037Z
2014-08-11T16:19:53.983Z
2014-08-11T16:19:53.983Z
Lindsey D
<p>I have 2 bits of code that should be about identical with the exception of one being in a Matrix and one not. The bit that is not looks like this:</p>

<pre><code>&lt;ul&gt;
    {% for point in entry.keyPoints %}
        &lt;li&gt;
            &lt;div class="a-ico"&gt;
                &lt;i class="fa fa-{{ point.icon }}"&gt;&lt;/i&gt;
            &lt;/div&gt;
            &lt;div class="a-info"&gt;
                &lt;h4&gt;{{ point.heading }}&lt;/h4&gt;
                {{ point.text }}
            &lt;/div&gt;
        &lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;
</code></pre>

<p>This works exactly as intended. and uses the "ICON" 3rd-party field type which essentially is a dropdown that allows me to pick which icon I want to use.</p>

<p>The code that i'm having trouble with is:</p>

<pre><code>{% for block in entry.articleBody %}
    {% if block.type == "text" %}
         Some stuff here
    {% elseif block.type =="iconSection" %}
        {% if block.getPrev() %}
            {% if block.getPrev().type != "iconSection" %}
                &lt;ul&gt;
            {% endif %}
        {% else %}
            &lt;ul&gt;
        {% endif %}
        &lt;li&gt;
            &lt;div class="a-ico"&gt;
                &lt;i class="fa fa-{{ block.icon }}"&gt;&lt;/i&gt;
            &lt;/div&gt;
            &lt;div class="a-info"&gt;
                &lt;h4&gt;{{ block.heading }}&lt;/h4&gt;
                {{ block.text }}
            &lt;/div&gt;
        &lt;/li&gt;
        {% if block.getNext() %}
            {% if block.getNext().type != "iconSection" %}
                &lt;/ul&gt;
            {% endif %}
        {% else %}
            &lt;/ul&gt;
        {% endif %}
    {% elseif block.type =="video" %}
        some stuff here
    {% endif %}
{% endfor %}
</code></pre>

<p>It is saying Template Error (Array to String Conversion) with this bit highlighted:</p>

<pre><code>&lt;i class="fa fa-{{ block.icon }}"&gt;&lt;/i&gt;
</code></pre>

<p>As you can see the code is almost identical except it is BLOCK instead of POINT, and the block one is in a matrix where as the point item is not. What might be causing this and how might I resolve it?</p>

<matrix><array>
Array to string conversion Template Error
# Array to string conversion Template Error

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

I have 2 bits of code that should be about identical with the exception of one being in a Matrix and one not. The bit that is not looks like this:

    {% for point in entry.keyPoints %}
        
            
                
            
            
                {{ point.heading }}
                {{ point.text }}
            
        
    {% endfor %}


This works exactly as intended. and uses the "ICON" 3rd-party field type which essentially is a dropdown that allows me to pick which icon I want to use.
The code that i'm having trouble with is:
{% for block in entry.articleBody %}
    {% if block.type == "text" %}
         Some stuff here
    {% elseif block.type =="iconSection" %}
        {% if block.getPrev() %}
            {% if block.getPrev().type != "iconSection" %}
                
            {% endif %}
        {% else %}
            
        {% endif %}
        
            
                
            
            
                {{ block.heading }}
                {{ block.text }}
            
        
        {% if block.getNext() %}
            {% if block.getNext().type != "iconSection" %}
                
            {% endif %}
        {% else %}
            
        {% endif %}
    {% elseif block.type =="video" %}
        some stuff here
    {% endif %}
{% endfor %}

It is saying Template Error (Array to String Conversion) with this bit highlighted:


As you can see the code is almost identical except it is BLOCK instead of POINT, and the block one is in a matrix where as the point item is not. What might be causing this and how might I resolve it?

**Tags:** matrix, array

---

## 1 answers

### Answer by username_1 on 2014-08-11. Score: 3 | Accepted answer

According to the docs for the Icons plugin, icon is actually an object. Try this instead...


In both scenarios, I'd take another look at your rendered HTML... your first example may actually be rendering the word Array instead of the class name that you are looking for. You can also leave off the leading fa-, since that will be automatically included in the class name.
Where you have called icon in both examples, you're simply referring to the field itself. You actually want to be referring to the values of the field.
To output the HTML you're looking for, either of these two options will work:

{{ block.icon.icon }}


And for your non-matrix example, just replace block with point.

> **Comments:**
> **username_0**: This worked, any idea why it worked without that in one instance and required it in another?  
> **username_1**: Are you sure the `point` instance was generating the right HTML code? (Was the icon actually showing up?) According to the plugin docs, that code snippet shouldn't have worked.  
> **username_0**: Yep, showed up and worked EXACTLY as intended.  

---

