Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Last active December 20, 2015 18:19
Show Gist options
  • Save bastianallgeier/6175390 to your computer and use it in GitHub Desktop.
Save bastianallgeier/6175390 to your computer and use it in GitHub Desktop.
This is some fancy new stuff coming in Kirby 2.
<?php
# Page modification API
// modifying pages
$page = page('portfolio/project-a');
$page->title = 'A wonderful project';
$page->text = 'This project is just an example…';
$page->year = '2013';
$page->likes = 0;
$page->likes->increment();
$page->likes->decrement();
$page->save();
// deleting pages
$page->delete();
// sorting pages
$page->sort('first');
$page->sort('last');
$page->sort(5);
$page->sort('up');
$page->sort('down');
// make pages visible/invisible
$page->make('visible');
$page->make('invisible');
$page->toggle();
// moving pages
$page->move('totally/different/parent/page');
// change the page's template
$page->changeTemplate('mytemplate');
# File modification API
// modifying file meta data
$file = page('portfolio/project-a')->images()->find('picture.jpg');
$file->title = 'This is a wonderful picture';
$file->caption = 'A fancy filter is missing though';
// deleting files
$file->delete();
// renaming files
$file->rename('super-picture');
@mrflix
Copy link

mrflix commented Aug 7, 2013

Awesome! Really looking forward to this.

@azharc
Copy link

azharc commented Aug 8, 2013

This is super. Can't wait!

@maguay
Copy link

maguay commented Aug 9, 2013

Insane you can get it that simple. Cannot wait to get my hands on it!

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