Skip to content

Kirby 3.7.5

Content locking with virtual pages

Prevent concurrent edits via the Panel

By default, the Panel will try to lock a page if a user makes unsaved changes to it to prevent another user to make changes at the same time.

Kirby creates a .lock file in the directory of the content file, retrieved via Page::contentFileDirectory(). However, your virtual page might not support any content file directory. Let's see how to deal with these cases.

Disable content locking

In many cases of virtual pages, content locking might not be desired. If you want to disable content locking for your virtual page, add a lock() method to your page model which returns null:

/site/models/reviews.php
<?php

class ReviewsPage extends Page
{
    public function lock()
    {
        return;
    }
}

Support content locking

To support content locking for your virtual page, Kirby expects a lock() method in your page model. The method needs to return an object of a custom class that handles the various content locking features:

/site/models/reviews.php
<?php

class ReviewsPage extends Page
{
    public function lock()
    {
        return new CustomContentLock($this);
    }
}

Check out the default Kirby\Cms\ContentLock class documentation as well as source code to learn more about the methods required to be implemented by your custom content lock class.