Welcome Guest, Not a member yet? Register   Sign In
How to code a maintenance "plug-in"?
#1

[eluser]IamPrototype[/eluser]
Hey, I need to code a maintenance page for my community, but instead of copy/past a code to every file I got, I was thinking if there was another way to do it? Like the WordPress "plug-in". I guess I could do something with my index.php file? Or am I completely wrong? Thank you! Smile

Edit: And I would like to code it this way so admins still have access to the website while guest/visitors can't enter.
#2

[eluser]TheFuzzy0ne[/eluser]
I can think of perhaps 10 different ways off the top of my head. The simplest being to just set up a route at the top of the list:
Code:
$route['.*'] = 'maintenance_controller';

Obviously you just need a maintenance controller, and you just comment out the route to disable it.

Note: I'm assuming that you don't need admin access to the site during maintenance mode, as that route will just shut everyone out. If you do require admin access, you could add a bit more logic to make up for that.
#3

[eluser]IamPrototype[/eluser]
Thank, I knew that.. but I won't have to edit my routes everytime I need a maintenance. I was thinking of a activate/de-activate button in my admin section Smile
#4

[eluser]TheFuzzy0ne[/eluser]
This can be implemented as an extension to the controller class. You could easily have it work in the constructor. If you're only planning on having a single row in the database, you could also have your script create a file instead, that would signify that the site is in admin mode. If the controller constructor sees this, it knows to redirect to the maintenance controller. Obviously, your script would also delete the file when your done.

Your code would have to only be fired if the user is not admin, or if the the requested controller is not your maintenance controller




Theme © iAndrew 2016 - Forum software by © MyBB