If I didn’t have web development, my English would be waaay worse now. Learning by doing.
Maybe this text look to a german, what a german text look to a swedish guy like me?
Nu skriver jag lite på svenska. Det går väldigt snabbt för mig att skriva på det här språket, men jag antar att väldigt få människor kommer att kunna läsa det eftersom jag bara har sett en enda svensk person här. Jag undrar om detta ser lika oläsbart ut för någon från tyskland som tyska ser ut för någon från sverige. Jag funderade på att översätta delar av Kirby men så såg jag att en svensk redan hade gjort det jobbet så jag har avvaktat med det. Dock finns det vissa ord som skulle kunna översättas bättre så någon gång i framtiden kanske jag tar mig tiden att förbättra den översättningen.
A beauty, or an encoded mess? A foreign language often look a bit like a mess.
Thanks, @jenstornell, for the demonstration. It’s always interesting to see how much you can understand of a foreign language;-) Not a lot, I must admit, but some words at least.
Anyway, gott nytt år, @jenstornell, and a happy new year to the rest of the community
@texnixe Glückliches neues Jahr! (I hope Google Translate did a good job and that I didn’t write someting nasty).
Thanks for the great idea. How would I get a router to check whether $site->maintenance() is on or off?
The router wouldn’t check if maintenance mode is on in Sonja’s example, it would listen on something like /maintenance
and render the error page. The line of code for the header snippet would then redirect to this virtual page.
Thanks lukas. So how would that be any different than just creating a template for the maintenance page? Why would you want any router action at all?
You would not have to create a page and instead call the template via the router. Since you might want to edit it’s contents, the router is probably not that useful; it’s a way of hiding that page from the panel, though.
i dont use that anymore, but!, its very very Helpfull !
Thanks all. Great to know about that hidden panel method @texnixe. The fewer pages for the client to see, the better!
Another advantage is that you can put all logic (detection of the maintenance mode and the template using a route) into a plugin that works on its own without changes in other parts of the site.
I’d love to get to that level. I’m close to figuring out how to load a custom template, but don’t know how to detect maintenance mode from a plugin–maybe checking the config file?
If the webserver prefers index.html
over index.php
your solution is the best!
If the webserver prefers index.php
over index.html
my solution is:
Open the file index.php
in the root of the Kirby installation and change the top of this file from
<?php
define('DS', DIRECTORY_SEPARATOR);
to
<?php
if(file_exists('maintenance.html')) {
require('maintenance.html');
die();
}
define('DS', DIRECTORY_SEPARATOR);
and follow the action from @tobiasweh in the quotation in the top of this post with the difference to change the file names maintenance.html
and index.html
in that description!
Good luck!
Hint:
If the directory /kirby
during an upload e.g. of a new Kirby version does not exist completely, the activation of a maintenance page using the panel can not work like
had said!
[Edit:]
Thanks @lukasbestle for your hint and your explanation! I have changed the code!
[Added:]
And follow
You need to build the html file without using any Kirby code and only with full qualified links e.g. to all css files and e.g. to the website logo like http://example.com/assets/images/logo.svg
(respectively https://...
).
That’s actually a very nice solution! However this won’t work for subpages (the redirection won’t work). What about this?
<?php
if(file_exists('maintenance.html')) {
require('maintenance.html');
die();
}
define('DS', DIRECTORY_SEPARATOR);
Thanks for your code. This can be used too.
But I cannot understand
I have changed the code in the Kirby root file index.php
, which is the starting point of Kirby. Every Kirby webpage is build by a call of this file!
If my if statements works, then no subpage is called by Kirby on my Win10 XAMPP installation.
http://php.net/manual/de/function.header.php
Only after stopping the maintenance the next renew of a page may lead to the Kirby error page.
It’s not that simple unfortunately. The index.php
is the starting point, but only a virtual one.
The actual URL the browser sees is for example http://example.com/
or http://example.com/projects/project-a
.
If you then send a redirection header with a relative URL, the browser will resolve it relatively to the current URL, in the second case this will result in http://example.com/projects/maintenance.html
, which will display a Kirby error page instead of the maintenance page even if maintenance is active.
Hi,
it would be nice if it would possible to use the global option from the site config also for this.
I have an option for develop as standard in my templates to switch some functions or files if the template is in developmode.
Or is there a possibility to overwrite all templates to another one like a maintenance template?
Another nice function would be if its possible to login on the maintance-file. So that allowed persons can see the website in development.
For this is use normal htpasswd. But with an maintance-file it looks better for people who are not allowed.
Cheers
Yes. You could conditionally register a route for the (:all)
pattern if the maintenance mode is on. That route will always be called before any template and you can control whether to give control to the normal template or whether to return the maintenance page based on a logged in user.
Please note that this setup isn’t really useful when doing things like updating Kirby. A static HTML page in front of everything will work more reliably.