Simple virtual page
Add an ad-hoc virtual page quickly via a simple route
Using Kirby's router, you can quickly create a new page from a route pattern:
Unless you have disabled UUIDs in your config, you have to pass a uuid
field in the content array to prevent Kirby from generating the page in the file system when the $page->uuid()
method is called.
If you generate the UUIDs automatically like in the example above, they will change at every load. However, if you want to reference your virtual pages anywhere with their UUID, make sure to use a unique string that does not change.
Create a virtual.php
template to output the content of the virtual page:
If you now open http://yourdomain.com/virtual
in the browser, you will see the new page.
It's also possible to create a multi-language version of this page, by adding the translations
array with the content for every language version.
These hard coded examples are not that useful yet, but they should already give you an idea how the factory
method helps us to create pages from whatever content we pass to it.