Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Created March 9, 2015 10:54
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastianallgeier/c34a99c54fa849f3adb0 to your computer and use it in GitHub Desktop.
Save bastianallgeier/c34a99c54fa849f3adb0 to your computer and use it in GitHub Desktop.
Most basic widget setup for panel widgets. You would put those two files in /site/widgets/mywidget/
<?php
return array(
'title' => 'Widget Title',
'html' => function() {
// any data for the template
$data = array();
return tpl::load(__DIR__ . DS . 'template.php', $data);
}
);
<!-- html for the widget -->
@eytanbiala
Copy link

Hey,

Is there a way to access $site or $page within the template?

@AugustMiller
Copy link

@eytanbiala You ought to be able to use the omnipresent page() and site() functions to return the active Page or Site objects… Although, I'm not sure what is to be expected from page(), given that we're not really in a standard Kirby front-end context.

(I haven't tried this!)

@plaidpowered
Copy link

I'd love to put widgets in the sidebar of the page/content editor...

@solastley
Copy link

I second this ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment