From time to time I feel the need for the creation of a “virual” page. A page that is not created as textfile but only exists as code.
Use registry extension to set it:
https://getkirby.com/docs/developer-guide/plugins/registry
It could use an array similar to this one:
https://getkirby.com/docs/cheatsheet/pages/create
array(
'title' => 'My new article',
'date' => '2012-12-12 22:33',
'text' => 'This is my new article',
'tags' => 'article, text, readable'
);
A use case. I create a route that read values from a database. In the current Kirby version there are two ways to show them.
1.
Use snippet
or tpl::load
to load a template or a snippet. The pitfall is that it is now unaware of $site
, $page
and $pages
. I could send them as argument but then they are not remembered in other snippets along the way down.
I can not use controllers.
2.
Create a real page in the Panel and in the route use visit
. The pitfall now is that I have a page in the Panel that I don’t need. The hackish way would be to hide it with CSS.
Because it’s a part of the content text file I can’t just move the plugin to another Kirby installation in the future because it’s now bound to the content as well.
Summery
If I could register a virtual page, it would be bundled with the plugin, not the content text files.
What will happend if the real content page exists? I think an existing page will always be used if it exists, just like the rest of the registry extensions.