In many of my v2 projects I use custom page models based on the page class. As of now, I am trying to upgrade a project to v3 and can’t get models in my plugin to work.
Because I have many models, I organize them in a subfolder of my plugin:
site/plugins/my-plugin/models
I do the same with templates/snippets:
site/plugins/my-plugin/templates
site/plugins/my-plugin/snippets
and loading them works fine via the given syntax:
Kirby::plugin('os/my-plugin', [
'templates' => [
'blog' => __DIR__ . '/templates/blog.php'
]
]);
Doing the same with the page model
Kirby::plugin('os/my-plugin', [
'pageModels' => [
'blog' => 'BlogPage'
]
]);
doesn’t work because there seems to be no way to get the right directory. Is there a way to do that? And why is the syntax different? I expected something like this (where I can set the directory):
Kirby::plugin('os/my-plugin', [
'pageModels' => [
'blog' => __DIR__ . 'blog.php'
]
]);
I get that Kirby needs to know the class it should load (which would not be known in my example), but what about the folder it is in?