Last active
July 13, 2017 14:19
-
-
Save bastianallgeier/9b77af3290a5bbe56c500ebee3fa49d5 to your computer and use it in GitHub Desktop.
Kirby CRUD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// create a main page | |
try { | |
$newPage = site()->children()->create($uid = 'test', $template = 'test', [ | |
'title' => 'A page title', | |
'date' => '2016-02-21', | |
'text' => 'Lorem ipsum dolor set amet ...' | |
]); | |
} catch(Exception $e) { | |
echo $e->getMessage(); | |
} | |
// create a subpage | |
try { | |
$newPage = page('services')->children()->create($uid = 'test', $template = 'test', [ | |
'title' => 'A page title', | |
'date' => '2016-02-21', | |
'text' => 'Lorem ipsum dolor set amet ...' | |
]); | |
} catch(Exception $e) { | |
echo $e->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
page('test')->delete(); | |
} catch(Exception $e) { | |
echo $e->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
page('mypage')->update([ | |
'title' => 'A new title', | |
'text' => 'Some text', | |
'anotherfield' => 'Some more data' | |
]); | |
} catch(Exception $e) { | |
echo $e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍