Maintenance mode

Hi,

I need to create a "Maintenance mode" switch in the cmsBuilder for my client's project, where from a checkbox i can disable the access to the website and redirect all users to a temporary info page until the switch is on.

Is there any way/function to embed this feature in the websiteMembership and made simplest the integration.

Thank you in advance,
Karls

By Damon - September 24, 2015

Hi Karls,

Here is one way that you can create a "Maintenance mode" switch for CMS Builder:

  1. Create a new Section Editor called Site Settings (single record)
  2. Create a checkbox field type call Maintenance Mode. The checkbox default state is Unchecked. Add a Field Description : Check this box turn Maintenance Mode on. 
  3. Generate the code for this Section Editor. 
  4. Add this code to the top of your Membership login page and any other site pages:

    // load record from 'site_settings'
    list($site_settingsRecords, $site_settingsMetaData) = getRecords(array(
    'tableName' => 'site_settings',
    'where' => '', // load first record
    'allowSearch' => false,
    'limit' => '1',
    ));
    $site_settingsRecord = @$site_settingsRecords[0]; // get first record

    //redirect if set to maintenance mode
    if($site_settingsRecord['maintenance_mode'] == 1) { header('Location: http://example.com/maintenance.php'); die; }

  5. Change the header location (redirect URL) to your temporary page.

That should be it. Try it out and test it. 

Let me know if you have any questions or need anything else.

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Hi Damon,

Thank you, this is the solution that i already .
I search for an alternative version, that i can make global from the wensiteMembership add-on if its possible.

I have separatedmember table and login from CMS with:

$GLOBALS['WSM_ACCOUNTS_TABLE'] = 'members';
$GLOBALS['WSM_SEPARATE_LOGIN'] = true;

and i need to redirect users only for the 'members'  rable.

Any suggestion?
Karls

Hi Damon,

Thank you for the support on this, I'll go with your first suggestion.

Karls