<p>I'm sure the documentation could be better, but this has nothing to do with Duct Video, it's simply a user error. Although a common one, when accessing things inside a matrix, assets field, or similar.</p>

<p>When you do:</p>

<pre><code>{% for video in entry.videos %}
</code></pre>

<p><code>video</code> is a matrix block. Not the field you've created inside that matrix blocktype. When accessing video.videoUrl, you get the an object of type Videos_VideoModel, same as when you add this field directly to an entry type. The correct way to do this (disregarding that videoUrl is a bad name for the video field) would be:</p>

<pre><code>{% for block in entry.videos %}
  {% set video = block.videoUrl %}
  &lt;ul&gt;
    &lt;li&gt;title: {{ video.title }}&lt;/li&gt;
    &lt;li&gt;url: {{ video.url }}&lt;/li&gt;
    &lt;li&gt;embed: {{ video.embed({ width: 300, height: 200 }) }}&lt;/li&gt;
  &lt;/ul&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-07-02T11:19:01.537Z
Thanks for the detailed response. This is how I have it setup now and it works great
Bryan Garrant
CC BY-SA 3.0
2015-07-01T14:53:02.927Z
2015-07-02T10:12:08.980Z
2015-07-02T10:12:08.980Z
André Elvan
<p>I have the plugin Dukt Videos installed to latest version 1.0.31.  I setup a Matrix block field with these settings:</p>

<p>Field handle: videos
Matrix Block handle: videoBlock
Matrix Video Field: videoURL</p>

<p>For some reason this will not work:</p>

<pre><code>{% for video in entry.videos %}
    &lt;ul&gt;
        &lt;li&gt;title: {{ video.title }}&lt;/li&gt;
        &lt;li&gt;url: {{ video.url }}&lt;/li&gt;
        &lt;li&gt;embed: {{ video.embed({ width: 300, height: 200 }) }}&lt;/li&gt;
    &lt;/ul&gt;
{% endfor %}
</code></pre>

<p>I get this error: Craft\MatrixBlockModel and its behaviors do not have a method or closure named "embed".</p>

<p>When I try this it also does not work:</p>

<pre><code>{% for blockMedia in entry.videos %}
    {{ blockMedia.videoUrl }}
{% endfor %}
</code></pre>

<p>I get this error: Internal Server Error. Object of class Craft\Videos_VideoModel could not be converted to string</p>

<p>What am I doing wrong with this Dukt Videos Plugin?</p>

CC BY-SA 3.0
2015-07-01T14:36:35.613Z
There is an example in the files that shows how to do this. Please update the online docs as this is an important part in the usage. Thanks.
Bryan Garrant
<plugin-duktvideos><plugin-duktoauth>
I can't get Dukt Videos working in a Matrix field?
# I can't get Dukt Videos working in a Matrix field?

(Asked by: username_0 on 2015-07-01)

I have the plugin Dukt Videos installed to latest version 1.0.31.  I setup a Matrix block field with these settings:
Field handle: videos
Matrix Block handle: videoBlock
Matrix Video Field: videoURL
For some reason this will not work:
{% for video in entry.videos %}
    
        title: {{ video.title }}
        url: {{ video.url }}
        embed: {{ video.embed({ width: 300, height: 200 }) }}
    
{% endfor %}

I get this error: Craft\MatrixBlockModel and its behaviors do not have a method or closure named "embed".
When I try this it also does not work:
{% for blockMedia in entry.videos %}
    {{ blockMedia.videoUrl }}
{% endfor %}

I get this error: Internal Server Error. Object of class Craft\Videos_VideoModel could not be converted to string
What am I doing wrong with this Dukt Videos Plugin?

**Tags:** plugin-duktvideos, plugin-duktoauth

> **Comments:**
> **username_0**: There is an example in the files that shows how to do this. Please update the online docs as this is an important part in the usage. Thanks.  

---

## 1 answers

### Answer by username_1 on 2015-07-01. Score: 3

I'm sure the documentation could be better, but this has nothing to do with Duct Video, it's simply a user error. Although a common one, when accessing things inside a matrix, assets field, or similar.
When you do:
{% for video in entry.videos %}

video is a matrix block. Not the field you've created inside that matrix blocktype. When accessing video.videoUrl, you get the an object of type Videos_VideoModel, same as when you add this field directly to an entry type. The correct way to do this (disregarding that videoUrl is a bad name for the video field) would be:
{% for block in entry.videos %}
  {% set video = block.videoUrl %}
  
    title: {{ video.title }}
    url: {{ video.url }}
    embed: {{ video.embed({ width: 300, height: 200 }) }}
  
{% endfor %}

> **Comments:**
> **username_0**: Thanks for the detailed response. This is how I have it setup now and it works great  

---

