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:
It could use an array similar to this one:
'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.
tpl::load to load a template or a snippet. The pitfall is that it is now unaware of
$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.
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.
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.
Just to clarify: You can hide a page via blueprint, at least if it has it’s own blueprint
Oh, forgot about that. Thanks for the info.
The other problems with it still exists. With this second point it’s that I can’t bundle it with the plugin. My plugin will be dependent on the content text files.
It’s an interesting idea, we will keep this in mind for the future.
@jenstornell - could you explain your use case a bit more?
why do you need the virtual page? you could technically read from the db at the page you are showing right?
No need for the page in the Panel
I could read it on any page, yes but then I would need a page first. In my case there is no need to have the page in the panel because I’m not going to add any content to it.
I don’t need:
- A content page folder
- A content text file
- A blueprint
A route is not a page
I could create a route to “emulate” a page, but in that case it’s still a route, not a page. There are many problems with this approach, for exampe that
$site can’t be global in all the snippets. There are more things like, controllers don’t work etc.
Bundle with plugins
Let’s say I could have a virtual page created with my plugin.
When I move my plugin to a fresh Kirby installation, the virtual page exists magically. Else I need to create the page again in the new installation.
I think this feature could solve a lot of problems that we might not even think of yet. We might not even need to rely on routes that much.
I’ve jsut been getting very good at hacking kirby for my panel extension - so I was wondering if maybe I could figure something out for this, but… I would probably need a more concrete use case to test on/think about.
on the other side, I did see that in another thread someone suggested extending the templates, so maybe that would have been mine as well.
But I think (hope) this feature belongs to the core.
Yeah, I think such a feature would be quite helpful, or at least a route feature that passes on the site and pages objects.
+1 on this as I have fought a lot with this (I might have even found a solution)