This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I would like to access whether or not maintenance mode is currently active in my default layout. Something like this....
{% if not site.maintenance %}
{% component 'mySiteMenu' %}
{% endif %}
Put this in the code section of your layout:
function onStart() {
$this['maintenance_mode'] = \Cms\Models\MaintenanceSetting::instance()->is_enabled;
}
Then in your page:
{% if maintenance_mode %}
We're in maintenance, yo.
{% endif %}
Last updated
Awesome, for reference, I have the following in my layout's code section....
function onStart() {
$this['inMaintenance'] = \Cms\Models\MaintenanceSetting::instance()->is_enabled;
$this['backendUser'] = BackendAuth::getUser();
}
And in my layout....
{% if backendUser or not inMaintenance %}
{% component 'headerMenu' %}
{% endif %}
Thanks again!
Last updated
These examples will give errors, it should be MaintenanceSetting, without the "s".
Like:
use Cms\Models\MaintenanceSetting; function onStart(){ $this['frontend_maintenance'] = MaintenanceSetting::instance()->is_enabled; }
See: https://octobercms.com/docs/api/cms/models/maintenancesetting
Last updated
1-6 of 6