Skip to content

Kirby 6.0.0

Pages

With the Pages extension you can register pages from a plugin that do not physically exist in the file system.

/site/plugins/pages/index.php
<?php

Kirby::plugin(
    name: 'my/plugin',
    extends: [
        'pages' => [
            'new-page' => new Page([
                'slug'     => 'new-page',
                'template' => 'virtual',
                'content'  => [
                    'title' => 'Hello'
                ]
           ])
        ]
    ]
);

If you want to use a model with your Page, you have to define the model in your plugin and then create an instance of your page model:

class VirtualPage extends Page
{
    // your custom page methods
}

Kirby::plugin(
    name: 'my/plugin',
    extends: [
        'pageModels' => [
            'virtual' => 'VirtualPage'
        ],
        'pages' => [
            'new-page' => new VirtualPage([
                'slug'     => 'new-page',
                'template' => 'virtual',
                'content'  => [
                    'title' => 'Hello'
                ]
           ])
        ]
    ]
);