Maintenance mode

By ht1080z - September 20, 2015

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/

By ht1080z - September 24, 2015

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

By Damon - September 25, 2015

Hi again,

It sounds like you want to just the members to be redirected. Here is one way to do this:

Change this:
 $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']  = '/'; 
to instead go to a page that checks if the site is in Maintenance mode (redirects to maintenance page) or Live (redirects to logged in content).

This would use the same "Maintenance mode" switch for CMS Builder and the code from above.

Once setup, you simply check the box in CMS Builder to turn maintenance mode (for members) on or off.

Hopefully this is a workable solution for you. If not, can you give me more details about what you are looking for.

Thanks!

Cheers,
Damon Edis - interactivetools.com

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