Maintenance Mode in Kirby?

Hello Kirby Family!,

As you know, So many Content Managment Systems Have a “Maintenance Mode” i think you Know What this is!, so why can not invent something even for Kirby?. There is something like this
or that is unnecessary?

Let me Know what you think about that! :smiley:

Best Regards Simon

This feature does not exist, but you can easily implement it yourself, e.g.

in your site.php blueprint add a field maintenance:

maintenance:
    label: Maintenance
    type: checkbox
    text: Enable Maintenance

Then add a new invisible page called maintenance with a text file called maintenance.txt and a maintenance.php template. Add the text you want to display when in maintenance mode. Alternatively, you can use a router to achieve the same.

Then in your header snippet add this:

<?php if($site->maintenance()->isTrue() and $page->uid() != 'maintenance') { go('maintenance');} ?>
2 Likes

ist es so richtig? :confused: die maintenance.php und die maintenance.txt sind Leer!

The maintenance.txt file needs to go into the maintenance folder.

Ich habe es gemacht, aber es Passiert nichts :confused:

You are not redirected to the maintenance page?

WOW :open_mouth: it works!, aber es soll Ja so Funktionieren das man die ganze seite nicht mehr sehen kann, mit einer Nachricht “Wir sind gerade nicht Erreichbar”, wie mach ich das :confused:

Wenn “Enable Maintenance” wahr ist, wird jede Seite (außer der Maintenance Seite selbst) zu Maintenance weitergeleitet. Alles was jetzt noch fehlt, ist ein bisschen Inhalt in der maintenance.txt Datei, z.B.

title: Wartungsmodus
----
text: Diese Seite wird gerade gewartet. Wir sind bald wieder da.

Du kannst im Maintenance template auch ein header snippet ohne Menü benutzen bzw. das Menü nur anzeigen, wenn die Page UID nicht “maintenance” ist.

header.php snippet:

<?php if($site->maintenance()->isTrue() and $page->uid() != 'maintenance') { go('maintenance');} ?>
<!DOCTYPE html>
<html lang="en">
<head>

  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1.0">

  <title><?php echo $site->title()->html() ?> | <?php echo $page->title()->html() ?></title>
  <meta name="description" content="<?php echo $site->description()->html() ?>">
  <meta name="keywords" content="<?php echo $site->keywords()->html() ?>">

  <?php echo css('assets/css/main.css') ?>

</head>
<body>

  <header class="header cf" role="banner">
    <a class="logo" href="<?php echo url() ?>">
      <img src="<?php echo url('assets/images/logo.svg') ?>" alt="<?php echo $site->title()->html() ?>" />
    </a>
    <?php if($page->uid() !== 'maintenance') snippet('menu') ?>
  </header>

(ich mach mal auf englisch weiter …)

Depending on what work/actions you consider to be maintenance using Kirby to set up this page could be problematic. For example if you switch to maintenance-mode to upload a Kirby update (via FTP) which takes some time (slow internet connection or whatever) and when the visitor comes to the page a relevant part of the Kirby for could be inaccessible because of the FTP transfer sync.

To make a long story short: I’m using a plain index.html file showing the maintenance message while updating. My server is configured (as most other serves) to prefer index.html over index.php (the latter is the one starting the Kirby magic). After updating I rename index.html to maintenance.html to “disable” maintenance mode.

muss das in snippets/header.php ?, wenn ja in welche Zeile

@tobiasweh You have a point there, but your solution can’t be done from the Kirby panel and @simondev was asking for a way to integrate a maintenance mode into Kirby.

If you use Git to deploy your site, you don’t have this sort of delay and would not need a maintenance mode for the few seconds it takes to update your site.

1 Like

@simondev The code I posted above is the complete header snippet with the additions already in there.

@texnixe wenn ich meine normale seite also 127.0.0.1/kirby aufrufe kommt das!, aber wenn ich die seite aufrufe kommt das

Your page uid has changed to “wartungsmodus”. Have you changed the code in the header snippet accordingly?

ich habe den Fehler gefunden und es Hat Funkioniert :smiley: , vielen Dank für ihre Hilfe :slight_smile:

Sure, I just wanted to point out that using (a custom) panel function for maintenance could be useless in some cases.

Thanks a lot @tobiasweh :slight_smile: !, Merry Christmas and Happy Holidays :smiley:

Ebenfalls allen frohe Weihnachten und einen guten Rutsch :smile:

@tobiasweh Ja, ich habe ja oben geschrieben, dass du mit deinem Hinweis absolut Recht hast :smiley:

Euch auch frohe Weihnachten und ein glückliches neues Jahr.

2 Likes

Could we keep the threads in english?

3 Likes