Maintenance Mode in Kirby?

Sorry @jenstornell but my English its not rly The best :confused: German is Rly Better For me

You don’t have to write perfect English to make yourself understood. For many of us here, English is not our mother tongue and so we are bound to make mistakes.

For the rest of the community who do not speak German, it’s certainly more helpful if they understand the solutions and can search for it in English as well.

2 Likes

But my Problem is, i dont know all words in English

Just think about it as a chance to communicate in English and learn more along the way (Google is there to help …). In development, you will hardly get by without English, anyway.

4 Likes

If I didn’t have web development, my English would be waaay worse now. Learning by doing. :wink:

1 Like

Thanks @lukasbestle and @texnixe :blush:

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.

1 Like

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 :stuck_out_tongue_winking_eye:

4 Likes

@texnixe Glückliches neues Jahr! (I hope Google Translate did a good job and that I didn’t write someting nasty). :slight_smile:

3 Likes

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 :slight_smile: !

Thanks all. Great to know about that hidden panel method @texnixe. The fewer pages for the client to see, the better!

1 Like

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://...).

1 Like

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.