View / Preview and Edit Site while in Maintenance Mode

Permalink
When logged in as super user / admin, I still cannot preview the site or work on content/pages etc. and can't see what already existed. Yes, I can get to the dashboard, but I can't edit content/pages, etc.

I have tried the .htaccess method as describe herehttp://www.concrete5.org/community/forums/chat/maintenance-mode-dur...

and I've tried the sticky post here describing how to do it.

http://www.concrete5.org/documentation/how-tos/administrators-maint...

NEITHER have made my site viewable or accessible to the front end.

Any help would be more than appreciated. It's practically impossible to develop a site or make basic changes while in maintenance mode but I don't want my site public yet (and I'd really rather not go the subdomain route for many different reasons.) Surely there is something we can change in the code to allow admin access to front end while in maintenance mode. I know there a several unanswered questions in the forum about this topic, so I'm posting again. Again, thanks in advance for any help you can provide.

firehouse
View Replies: View Best Answer
LucasAnderson replied on at Permalink Reply
LucasAnderson
I've managed to make my front end appear to me in maintenance mode. I guess I would recommend following the how-to first, but since you tried that I'll post what worked for me.

Find and open/edit /concrete/startup/maintenance_mode_check.php

replace it all with this:

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::model('user');
if ((!$c->isAdminArea()) && ($c->getCollectionPath() != '/login')) {
   $smm = Config::get('SITE_MAINTENANCE_MODE');
   $u = new User();
   if ($smm == 1 && $u->getUserName() != "admin") {
      $v = View::getInstance();
      $v->render('/maintenance_mode/');
      exit;
   }
}


making sure to change the "admin" part of this line to whatever your admin username is:

if ($smm == 1 && $u->getUserName() != "admin")


NOTE: This is by no means the perfect way and is probably not the best, but since you were having trouble with the other way maybe this will help.
firehouse replied on at Permalink Reply
firehouse
Thank you, thank you, thank you!!
That worked for me.

If I can bug you for one more thing, what if I want to assign more than one username access, how would you write that, as in more than one admin should be able to access front end (add more than one username)?
LucasAnderson replied on at Permalink Best Answer Reply
LucasAnderson
Again, that's probably where the How-To would be better since it uses groups and not specific usernames. You would add any users that you want to have access to a specific group, say "Designers".

So, create a new group called Designers

Then add your users to it (including you) that want access to the front-end in maintenance mode.

Then do the same thing as my original post except replace the file with the code below:

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::model('user');
$u = new user();
$g = Group::getByName('Designers');
if ((!$c->isAdminArea()) && ($c->getCollectionPath() != '/login')) {
   $smm = Config::get('SITE_MAINTENANCE_MODE');
   $u = new User();
   if ($smm == 1 && !$u->inGroup($g)||!$u->isSuperUser()) {
      $v = View::getInstance();
      $v->render('/maintenance_mode/');
      exit;
   }
}


Hopefully that works.
firehouse replied on at Permalink Reply
firehouse
Yes, this worked perfectly! Thank you. If ever I can help you with anything design related, just let me know.
aghouseh replied on at Permalink Reply
aghouseh
One bug I found with this is that in the conditional for the Super User check, you had OR instead of AND, which made non-appropriately grouped Super Users fail the check and get the maint page.

?php
defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::model('user');
$u = new user();
$g = Group::getByName('Designers');
if ((!$c->isAdminArea()) && ($c->getCollectionPath() != '/login')) {
   $smm = Config::get('SITE_MAINTENANCE_MODE');
   $u = new User();
   if ($smm == 1 && (!$u->inGroup($g) && !$u->isSuperUser())) {
      $v = View::getInstance();
      $v->render('/maintenance_mode/');
      exit;
   }


That should do the trick.
melat0nin replied on at Permalink Reply
melat0nin
Hi Lucas

Sorry to dredge this thread up, but it's not working for me on a 5.4.1 installation. I tried it on a 5.4.1.1 and it worked great.

I still see the maintenance page when logged in as admin. Even when I rename maintenance_mode_check.php admin mode still comes up - the file isn't even being called. It's definitely the right one - /concrete/startup/maintenance_mode_check.php

Bizarre!
OliR replied on at Permalink Reply
Just to confirm i'm having the same issue when using 5.4.1.1
Have tried a few past solutions from searching the forums but nothing seems to work on the latest release... Hopefully someone can help?
melat0nin replied on at Permalink Reply
melat0nin
I had a strange problem relating to multiple installations (not a c5 issue) which resolved the maintenance mode problem once fixed.

Unfortunately that doesn't help you :(
OliR replied on at Permalink Reply
At least you got yours sorted, which gives me a glimpse of hope that it should be working :p

Have i missed out anything or should it be as simple as going into maintenance mode and then editing the maintenance_mode_check.php with the code shown above? Selecting in the code either a certain username or just a general group such as admin.
melat0nin replied on at Permalink Reply
melat0nin
Well I thought I had it working, but it only seems to operate as expected on one site and not the others. Back to the drawing board...

It should be that simple but something tells me maintenance_mode_check.php is being ignored, even though it's called in dispatcher.php. If you remove maintenance_mode_check.php (just rename it) the site still operates as though nothing has changed.
OliR replied on at Permalink Reply
Should these methods still work using the latest version of c5? After editing the maintenance_mode_check.php in the core files with the above I'm still not being able to view or edit any pages. I've tried from the admin group, and also tried the suggestion of using the "designers" group and assigning it in the code. Any other tips i could try? Thanks for any help.
PanAura replied on at Permalink Reply
PanAura
The best solution to this problem is to simply install an add-on from the marketplace called "Maintenance Editor" by mkly. Once it is installed, you will find the custom settings located in your dashboard. Make sure your default maintenance mode is disabled before activating the add-on. You should be able to navigate to any page via the sitemap and then edit the individual pages while in Maintenance mode. It's a Great add-on and it is FREE!