Register Page models inside plugin

I’d like to create a custom page model inside a plugin.

I have set

'pageModels' => [
   'subscriber' => 'SubscriberPage'
],

and a class definition inside index.php, as that’s how the official docs say to do it. (Page models | Kirby)

But I would like to move that into a myplugin/models/subscriber.php file. Is that possible?

Check out how it’s done in the getkirby.com repo:

1 Like

Thanks a lot! (Edit: will marked as solved when I managed to do it myself :smiley: )

Hm, not sure if this is enough for me to understand. I’m still getting a “class not found”. The difference between this and my plugin is that the repo you posted uses composer autoloader, but I’m using kirby’s load() helper – could this be the error? is there a tutorial on how to set that up correctly?

Edit: nevermind about that, my models folder was outside the plugin directory… I think I can figure out the rest.

Thanks for posting the repo, this will surely be of help. Still, if there’s any resources on how to set up autoloading correctly, I’d be very grateful! :~)