0

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 %}
    <ul>
        <li>title: {{ video.title }}</li>
        <li>url: {{ video.url }}</li>
        <li>embed: {{ video.embed({ width: 300, height: 200 }) }}</li>
    </ul>
{% 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?

1
  • 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. Jul 1 '15 at 14:36
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 %}
  <ul>
    <li>title: {{ video.title }}</li>
    <li>url: {{ video.url }}</li>
    <li>embed: {{ video.embed({ width: 300, height: 200 }) }}</li>
  </ul>
{% endfor %}
1
  • Thanks for the detailed response. This is how I have it setup now and it works great Jul 2 '15 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.