Oembed and Structured Fields

Hey all, I’m new to Kirby (as in about a ~week) as well as php.

I’m building out a simple portfolio site for a client that focuses mainly on video production. On their project page, I am attempting to use the oembed kirby plugin to display a series of videos/thumbnails on their project showecase page.

I would like them to be able to add projects via structured panel fields (title, description, video), by simply adding a link to a video from their vimeo account. I’ve got this working on simple fields, but can’t seem to get get it working for structured fields. Am I making an error? Or is this plugin the wrong direction to go in. Any advice much appreciated.

oembed works in the instance below

<div><?php echo $page->projecttest()->oembed(); ?></div> 

But seems to be failing here

    <?php foreach(yaml($page->projects()) as $project): ?>
      <section class="project">
        <h4><?php echo $project['projecttitle'] ?></h4>
        <div><?php echo $project['projectlink'] ->oembed(); ?></div>
    <?php endforeach ?>

$project['projecttitle'] is just a string, therefore methods don’t work. I don’t know the plugin but you could try to use the new toStructure()method to output the structure field, i.e. instead of

$page->projects()->yaml(); //this is the new chained syntax for the yaml() method


$projects = $page->projects()->toStructure();
  foreach($projects as $project): ?>
      <section class="project">
        <h4><?php echo $project->projecttitle() ?></h4>
        <div><?php echo $project->projectlink() ->oembed(); ?></div>
    <?php endforeach ?>


Not tested though …

1 Like

Wow, works perfectly. Thanks so much @texnixe

I assume, you refer to my plugin when you talk about the oembed plugin? If so, let me know when you have further questions :wink:

1 Like

Hi there,

I installed the plugins and works perfectly on local. But as soon as I put it online, on the server it does not work.
It says:
Parse error: syntax error, unexpected ‘[’ in site/plugins/oembed/lib/Essence/Essence.php on line 69

I’m bit lost, do you know something about that?


Atm the plugin requires PHP 5.5 or higher due to the libraries it uses. It looks like your server is on a lower PHP version. I’m trying to move to better libraries that have not such requirements. But I can’t say when that’ll happen.

I’ve updated the PHP version on my server and it works, that’s great.
Thank you a lot for your help.