PHP code example of sgkirby / micropublisher
1. Go to this page and download the library: Download sgkirby/micropublisher library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sgkirby / micropublisher example snippets
'sgkirby.micropublisher.jwtkey' => '<YOUR-KEY-STRING>',
micropublisherEndpoints()
'sgkirby.micropublisher.jwtkey' => '<YOUR-KEY-STRING>',
'sgkirby.micropublisher.default.template' => 'post',
sgkirby.micropublisher.default.status' => 'draft',
sgkirby.micropublisher.default.parent' => 'blog',
'sgkirby.micropublisher.default.slug' => 'slug',
'sgkirby.micropublisher.default.render' => [
'name' => [ 'title', 'No title' ],
'content' => [ 'text', '' ],
'category' => [ 'tags', null ],
'published' => [ 'date', strftime( '%F %T' ), 'datetime' ],
],
'sgkirby.micropublisher.posttypes' => [
// internal name of post type (unique) *1
'note' => [
// human-readable name (optional) *2
'name' => 'Note',
// Kirby template name (optional) *3
'template' => 'note',
// status of the newly created post (optional) *4
'status' => 'listed',
// the parent page for new posts of this type (optional) *5
'parent' => 'notes',
// the rules to identify incoming posts of this type (optional) *6
'identify' => [
'unique' => null,
'has' => [ 'content' ],
'hasnot' => null,
],
// the rendering rules for this post type *7
'render' => [
'name' => [ 'title', 'No title' ],
'content' => [ 'text', '', function( $value, $fieldname, $default ) {
return $value
} ],
'category' => [ 'tags' ],
'published' => [ 'date', strftime( '%F %T' ), 'datetime' ],
'checkin' => [ 'checkin', null, 'yaml' ],
],
// handling of uploaded media files (optional) *8
'files' => [
'photo' => [ 'image', true, false ],
],
// slug building rules (optional) *9
'slug' => [ 'slug', 'title', [ 'text', 30 ] ],
// target language (optional) *10
'language' => 'en',
],
],
'status' => ['listed', 'draft'],
'status' => 'listed',
'identify' => [
'unique' => 'reply-of',
],
'identify' => [
'has' => ['name', 'location'],
],
'identify' => [
'hasnot' => ['photo'],
],
'render' => [
'category' => ['tags'],
'render' => [
'name' => ['title', 'No title'],
'render' => [
'published' => ['date', strftime('%F %T'), 'datetime'],
'render' => [
'location' => ['checkin', null, 'yaml'],
'render' => [
'content' => ['text', '', function($value, $fieldname, $default) {
return [
'title' => 'Modified',
$fieldname => $value . ' and some more text',
]; }
],
'files' => [
'photo' => ['image', false],
],
'files' => [
'photo' => ['image', true, 'cover'],
],
'files' => [
'video' => false,
'audio' => false,
],
'slug' => 'slug',
'slug' => ['slug', 'title', ['text', 30]],
'language' => 'en',
'sgkirby.micropublisher.categorylist.array' => ['tag1', 'tag2', 'tag3'],
'sgkirby.micropublisher.categorylist.parent' => 'blog',
'sgkirby.micropublisher.categorylist.taxonomy' => 'tags',
'sgkirby.micropublisher.endpoint' => 'micropub',
'sgkirby.micropublisher.slugprefix' => 'my-prefix-',
'sgkirby.micropublisher.slugprefix' => date('Y') . '-' . date('m') . '-',
'sgkirby.micropublisher.syndicate-to' => [],