Hello. Is there a way to play a video in a modal within the panel? I like to create a collection of how-to videos and offer links to them from a new widget on the dashboard. Clients love it and it saves me tons of training time. The videos open in a new tab over at YouTube. It’d be great if the video could play in a modal. Any ideas on how to make this happen. I understand anything 's possible, but I’m not interested in deeply hacking things.
Well i would also be interested in how to properly create modals with fields/wigets.
To use the Kirby modal you need to add data-modal
to the link that should open the modal. The href
attribute must point to a route where you can fetch the modal from.
<a href="youtube/UFmQrQxr7EY" data-modal>Yay it's a modal</a>
Create a plugin to create your custom route. It could look something like this.
Not tested I just stripped down the code of this plugin.
if(!function_exists('panel')) return;
$panel = panel();
// Custom delte route
$panel->routes[] = array(
'pattern' => 'youtube/(:any)',
'action' => function($v) {
$controller = new Kirby\Panel\Controllers\Base();
return $controller->layout('app', array('content' => tpl::load(__DIR__ . DS . 'template.php', array('v' => $v))));
},
'filter' => 'auth',
'method' => 'POST|GET'
);
// template.php
<div class="modal-content">
<!-- do whatever you need to do here -->
https://www.youtube.com/watch?v=<?php echo $v; ?>
</div>
<!-- you can add a script tag to add some custom javascript -->
<script>
$(function() {
console.log('do something');
});
</script>
You probably need to add some more markup in the modal to make it look nice because normally the modal is for a form that has all the styling.
But it should be a good point to get started.
It isn’t exactly what you are looking for but maybe this plugin can help you.