Kirby 2.1.0

Panel

Hooks!!

Kirby 2.1 comes with a brand new hook system for almost any significant panel actions. You can create hooks in your config or plugins to execute code when a new page is being created, a user is being updated, a file is being deleted and much more.

The following hooks are now available:

  • panel.page.create
  • panel.page.update
  • panel.page.delete
  • panel.page.sort
  • panel.page.hide
  • panel.page.move
  • panel.file.upload
  • panel.file.replace
  • panel.file.rename
  • panel.file.update
  • panel.file.sort
  • panel.file.delete
  • panel.user.create
  • panel.user.update
  • panel.user.delete
  • panel.avatar.upload
  • panel.avatar.delete

A hook can be registered in a plugin file or in your site/config/config.php like this:

kirby()->hook('panel.page.create', function($page) {
  // your hook code
});

This addition offers a brand new set of possibilities.

Improved Structure field

Modals

A lot of you werent happy with the current state of structure modals. They were simply too small. All modals now adapt to the screen size and if the window gets too small, modals become scrollable, avoiding any usability issues.

The structure modals are now also way bigger than before giving you more space for form fields.

Additionally the Save button has been renamed to Ok, to not imply that changes in the modal are also automatically saved in the page.

Default values for structure fields

You can now set default values for structure fields in YAML:

  emails:
    label: Emails
    type: structure
    default:
      - email: bastian@getkirby.com
      - email: sascha@getkirby.com
      - email: nico@getkirby.com
    fields:
      email:
        label: Email
        type: email

Stored form data

Form data for pages is now stored, even if you switch to another page in the panel. Once you come back you can decide to discard the stored changes or keep on writing where you left.

Site files and new place for site options

The site options have moved to the menu and are no longer available as widget in the dashboard. This makes the dashboard clearer and the menu serves as a better/more logical entry to the options.

In the options users can now find the current Panel and Kirby versions, which will help during support.

A major new feature are the global site files, which can now be uploaded in the site options. You can access global $site files simply from the $site object:

$site->files();
$site->images();
$site->videos();
// etc.

Improved file uploader

Filename sanitization

Kirby's file uploader automatically sanitizes filenames to avoid broken links due to special characters in filenames. You can switch this off now in your blueprints with the new file sanitization option:

title: My blueprint
files:
  sanitize: false
fields:
  …

iOS uploads

The uploader has so far been broken on iOS for multiple files. iOS automatically uploads all image files as image.jpg, which leads to overwritten duplicates. Kirby takes care of this now.

New type option for files

With the new type option you can now set, which type of files are allowed for uploads:

title: My blueprint
files:
  type: image
fields:
  …

New size option for file uploads

With the new size option you can now limit file uploads by a maximum size in bytes:

title: My blueprint
files:
  size: 1221929
fields:
  …

New dimension options for file uploads

With the new dimension options (width and height) you can now determin the max width and height for uploaded images

title: My blueprint
files:
  width: 1000
  height: 1000
fields:
  …

You can set those separately to apply just one rule of course.

This works even with multiple types:

title: My blueprint
files:
  type:
    - image
    - document
fields:
  …

Improved file previews

The file viewer comes with improved previews for transparent PNGs and SVGs as well as better handling for thumbnails of large images.
GD lib can now created thumbnails for files up to a maximum of 2048 x 2048 pixels. If you switch the thumbnail driver to Imagemagick there's no more limit for thumbnails.

Selective button setup for textareas

The formatting buttons for textareas could be selectively switched off or on in Kirby 1. This option is now back:

label: My textarea
type: textarea
buttons:
  - bold
  - italic
  - link

New publish/unpublish option

The visible/invisible status for pages can now be changed directly in the sidebar of a page, which simplifies publishing and unpublishing of articles or pages massively.

Strict Markdown mode

You can now set the panel to strict markdown mode by switching off kirbytext tag support in your config:

c::set('panel.kirbytext', false);

This will make sure that the formatting buttons as well as drag and drop for files and links will generate pure markdown tags instead of Kirbytags.

Translations and RTL text

The panel now comes with a Traditional Chinese Translation and Arabic. The latter is only possible with the new right to left text option for all translations.

Moved to Sass

All panel css files are now moved to small Sass components to make it easier for everyone who wants to get involved and improve the styles for the panel.

Fixed sorting

A better sorting algo takes care to keep sorting correct even with lots of subpages. Sorting is now also updated when pages are being deleted.

More flexible dynamic options

Select fields, checkboxes and radio buttons now have improved dynamic options and option queries.

visibleSiblings and invisibleSiblings mode for options

Example A:

label: Select field
type: select
options: visibleSiblings

Example B:

label: Select field
type: select
options: query
query:
  page: projects/project-a
  fetch: invisibleSiblings

More flexible page option in queries

The page option now supports relative paths.
You can only move up in the pages tree though.

Example:

  label: Select field
  type: select
  options: query
  query:
    page: ../../../
    fetch: children

External API support for dynamic field options

You can now simply pass a URL for options to fetch a JSON array with keys and values for options:

  label: Select field
  type: select
  options: http://myoptionsapi.com/options.json

Make sure the JSON is in the following format:

{
 "key1" : "value1",
 "key2" : "value2",
 "key3" : "value3"
}

More changes

  • Better compatibility with Synology's file system
  • Shortcuts are not being fired in contenteditable elements for better plugin support
  • Fixed panel login on Android
  • Better versioning of panel assets for more stable updates
  • Fixed sorting of pages in the dashboard and max limit is now being considered
  • The custom panel css is now also loaded on the login page so you can style that as well
  • Fixed blueprint loading to avoid broken relations when templates are not written in the same case.
  • Password suggestions. Each password field now comes with secure password suggestions.
  • Updated Turkish translation
  • Updated Russian translation
  • Optional widgets. Widgets can now return false to not appear in the dashboard. This is great to ask for user roles and show/hide widgets accordingly.
  • Better compatibility with a relative base URL.
  • Multiple sorting option for subpages
  • Better readonly versions for textareas, checkboxes, tags and structures
  • Bugfix for distorted avatars in the dashboard
  • Fixed lowercase issues on tags fields

Core

New field methods

$page->myfield()->isNotEmpty();
$page->myfield()->isFalse();
$page->myfield()->isTrue();
$page->myfield()->toPage()->title();
$page->myfield()->toFile()->filename();
$page->myfield()->toStructure();
$page->myfield()->link();

Especially the new toStructure method is awesome. While the yaml method returned a simple associative PHP array for structured field content, the new toStructure method gives you a full blown Kirby Collection which makes it possible to use Kirby's chaining syntax:

For example…

Accounts:
- name: Twitter
  url: http://twitter.com/getkirby
- name: Github
  url: http://github.com/getkirby

can simply be turned into this:

<h1>On the web</h1>
<ul>
  <?php foreach($page->accounts()->toStructure() as $account): ?>
  <li>
    <a href="<?php echo $account->url() ?>">
      <?php echo $account->name()->html() ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

The new link method can be used to create a link for any field value:

<?php echo $page->title()->link() ?>

This will create a link with the title as link text and the page url as url.

Non-blocking session handling

So far Kirby could only handle one session per account. This meant that you could not login in your browser and on your phone with the same account at the same time, which of course sucked. This is now fixed.

More flexible cache.ignore option

The cache.ignore option can now handle wildcards for more flexible rules to ignore pages for the cache:

c::set('cache.ignore', array(
    'projects/*'
));

Better extensibility with additional options

You can now extend even more core functionalities with the following new options:

  • markdown.parser
  • smartypants.parser
  • css.handler
  • js.handler
  • date.handler

Those options can now take callbacks, which you can use to setup your own Markdown parser (if you are not happy with Parsedown i.e.) or to modify the js() and css() helpers to - let's say - create a cache busting plugin. BTW: I've already done that: https://github.com/getkirby/plugins/tree/develop/cachebuster :)

Check out the Kirby class for the base implementation to get started.

There has also been a bugfix in the smartypants parser, which is now fixed.

More flexible Thumbs Driver setup

You can now control where Kirby stores thumbnails by simply passing a callback to the thumbs.destination option:

c::set('thumbs.destination', function($thumb) {
  // return a path here where the thumbnail should be stored
});

Kirbytext improvements

Link to files in image tags

You can now assign a link to a document in an image tag:

<figure><a href="https://getkirby.com/a-document.pdf"><img src="https://getkirby.com/an-image.jpg" alt=""></a></figure>

Captions for videos

You can now set a caption parameter in youtube or vimeo Kirbytags to create a figure with a figcaption for the embedded iframe:

(youtube: http://youtube.com/v=aKdV5FvXLuI caption: Nice video!)

Better language support

Date Handler

You can now change Kirby's default date handler date() function to strftime() by simply adding

c::set('date.handler', 'strftime');

This is especially relevant for non-english websites, where you want to work with translated month names, which should react to the locale settings

RTL mode for multi-language sites

While we were at it in the panel, we also added the option to the reading direction mode for frontend languages in multi-language sites:

c::set('languages', array(
  array(
    'name'      => 'English',
    'code'      => 'en',
    'locale'    => 'en_US.utf-8',
    'default'   => true,
    'url'       => '/',
    'direction' => 'ltr'
  ),
  array(
    'name'      => 'العربية',
    'code'      => 'ar',
    'locale'    => 'ar_AE.utf-8',
    'url'       => '/ar'
    'direction' => 'rtl'
  )
));

You can work with this in your templates like this:

<?php echo $site->language('ar')->direction(); ?>

More flexible locale settings

You can now pass an array to Kirby's locale option to change each locale individually:

c::set('locale', array(
  LC_COLLATE  => 'tr_TR.utf8',
  LC_MONETARY => 'tr_TR.utf8',
  LC_NUMERIC  => 'tr_TR.utf8',
  LC_TIME     => 'tr_TR.utf8',
  LC_MESSAGES => 'tr_TR.utf8',
  LC_CTYPE    => 'en_US.utf8'
));

This also works for the locale setting in language setups.

New excerpt mode

You can now limit excerpts by the number of words instead of characters:

$page->text()->excerpt(100, 'words');

Additional changes

  • Fixed broken next/prev methods with missing parent
  • New Parsedown and Parsedown Extra versions
  • More tolerant inventory scan for multilang pages with a single language
  • You can now fetch a language with $site->language('de')
  • Fixed tiny url handling for multi-language sites
  • Better page object comparison in multiple methods
  • Page models are now being loaded correctly even with upper/lowercase templates or dots and dashes in template names.
  • Fixed a bug with switched on language detection breaking switching between languages on the home page.
  • Custom URL configuration is now being passed to the pagination object
  • Pages, page, files and file objects now have extensive new toArray and toJson methods, which are awesome for any kind of API output.
  • A missing site title does no longer break the panel.

Toolkit

Additional changes

  • Fixed iOS file uploads in the Upload class
  • New dimensions::toArray and media::toArray methods
  • Enabled socket based connections for the database class
  • Improved url::build and url::base methods
  • Memcache prefix option
  • Reply To option for Mailgun email driver
  • Improved visitor::ip
  • Added httpOnly argument to cookie::set
  • Updated cookie handling according to OWASP best practices
  • Added handler option for modified methods in f and media classes
  • Better compatibility for Synology files when scanning dirs
  • Improved mime type detection for xls and ppt files
  • Improved Russian string translation in str::slug
  • Added py and java file type detection
  • Used backticks for sql identifiers
  • Fixed quote types for default values in the sql class
  • Fixed url::hasQuery() method
  • New url::index() method
  • New xml::create() method
  • Reduced default quality setting for the thumb class
  • Fixed HTTPS detection issue in the URL class
  • Corrected HTTP status codes in the header class
  • Fix for str::ucfirst()
  • Improved invalid() method
  • Fixed database::dropTable() method
  • Better handling of HTML attribute data escaping

Our partners

CDN by KeyCDN Search by Algolia

Top