Quantcast
Viewing latest article 2
Browse Latest Browse All 4

cakePHP – Quick and Simple Maintenance page

How to setup a maintenance page in cakePHP – this is one of the ways:

Create new model:
app/models/offline.php

<!--?php
class Offline extends AppModel {
	var $name = 'Offline';
	var $useTable = false;
}
?-->

Create new controller:
app/controllers/offlines_controller.php

<!--?php
class OfflinesController extends AppController {
	var $name = 'Offlines';
	function index() {
		$this--->layout = ''; //empty layout - an example
		//$this-&gt;layout = 'header_only'; // I use my header-only layout which shows page header on the top
	}
}
?&gt;

Create new view:
app/views/offlines/index.ctp

<div style="font-size: 18px; text-align: center;">
<strong>We are currently taking care of your data. Please check back later.</strong></div>

and add following line on the top of
app/config/routes.php

//MAINTENANCE - uncomment when maintenance
Router::connect('*', array('controller' =&gt; 'offlines', 'action' =&gt; 'index'));

When this line is left uncommented then all requests are redirected to the app/views/offlines/index.ctp page.

Hope this helps.

Please LIKE, Share, ReTweet. Thank you.


Viewing latest article 2
Browse Latest Browse All 4

Trending Articles