Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Created April 6, 2016 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastianallgeier/38f895b32b71e8e2b2f3844e38df5489 to your computer and use it in GitHub Desktop.
Save bastianallgeier/38f895b32b71e8e2b2f3844e38df5489 to your computer and use it in GitHub Desktop.
<?php
// register a field
$kirby->set('field', 'author', 'field/author');
// register blueprints
$kirby->set('blueprint', 'blog', 'blueprints/blog.yml');
$kirby->set('blueprint', 'article', 'blueprints/article.yml');
// register a widget
$kirby->set('widget', 'visits', 'widgets/visits');
// register templates
$kirby->set('template', 'blog', 'templates/blog.php');
$kirby->set('template', 'article', 'templates/article.php');
// register snippets
$kirby->set('snippet', 'pagination', 'snippets/pagination.php');
// register controllers
$kirby->set('controller', 'blog', 'controllers/blog.php');
$kirby->set('controller', 'article', 'controllers/blog.php');
// register Kirbytags
$kirby->set('tag', 'article', [
]);
// register page models
$kirby->set('page::model', 'blog', 'MyPlugin\\Models\\Blog');
$kirby->set('page::model', 'article', 'MyPlugin\\Models\\Article');
// register all kinds of hooks
$kirby->set('hook', 'panel.page.update', function() {
});
// create page methods, pages methods, file methods and files methods
$kirby->set('page::method', 'comments', function() {
});
// set options
$kirby->set('option', 'blog.title', 'My Blog');
@fvsch
Copy link

fvsch commented May 7, 2016

Setting routes as well:

$kirby->set('route', [
  'pattern' => 'myroute',
  'action'  => function() {
    // Return a page object or false
  }
]);

@fvsch
Copy link

fvsch commented May 8, 2016

Is $kirby->set('controller', 'article', 'controllers/blog.php'); actually working?
With 2.3b2 in a plugin I had to give a full path to the controller file:

$kirby->set('controller', 'something', __DIR__ . DS . 'mycontroller.php');

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