Setting up the Breeze Website Builder™ to Edit Multiple Sites In One Account

Multi-site Breeze header

There are two ways to have multiple websites in one web-hosting account. One way is to create a sub domain and install the Breeze into the sub domain i.e. main site at example.com, other sites at sub1.example.com, sub2.example.com, etc. Each of the sub domains would be setup to use a folder under the webroot, i.e. sub1, sub2 etc. There is nothing special that needs to be done for this setup other than having a different Breeze Website Builder™ installed into each sub domain The drawbacks are that each installation needs its own set up Breeze files taking up disk space, and switching to which of the sites is seen at example.com a little more difficult than "flipping a switch". But this topic is not going to cover this method. Instead, we will talk about how to use the new multi-site feature built into Breeze versions 6.6.0 and later.

The second method to have multiple sites in one account is to use the new multi-site feature in Breeze versions 6.6.0 and later which provides for the following:

The key file for controlling which site is active and how many sites you have is config_sites.php which is found under connect/. The contents of this file are:

<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 7/5/2019 ELL
//

// Modification if this file allows for development of new website while old website remains inactive and unaffected.
// You will need to copy the /connect/ for and all of the files (except this one) to a new folder named /connect2/.
// Subsequent test sites may also be created by incrementing the number in the /connect2/ folder name, i.e.
// /connect3/, /connect4/, etc. You also need to copy the Breeze Website Builder database. At a minimum, your config.php
// file under /connectX/ will need to assign a different folder for BWB_CSS_DIR. If you want to have different web page
// files, you may also have a different folder for BWB_WEBPAGE_DIR. Alternatively, you may set a different folder for
// BWB_BASE_DIR (typically = '') which will have all of the website folders located under it.
//
// After copying your Breeze database, you will also need to change db_connect.php with the new database credentials.
//

// *** Active Site ***
// Default is 1. To activate the first additional site, change this to 2. Increment to add even more sites.
define('BWB_ACTIVE_SITE', 1);

// ***Site Count ***
// Default is 1. Set to the number of sites you have, i.e. active site plus test sites.
define('BWB_SITE_CNT', 1);

// *** Session Save Path ***
define('SESSION_SAVE_PATH', '/tmp');
// This is included here in addition to config.php because a session must be started before the config.php file is loaded
// to obtain the site_under_edit session value in order to determine which where the config folder is. This is because once
// a define is declared, it can not be overwritten simply by redefining it.
// Session save path is not defined on all servers by default. Default path on most severs is /tmp, but you may need to change
// this path to a folder within your hosting account for example. Note: do not use trailing slash '/'.
?>


BWB_ACTIVE_SITE defines which site is active. By default this is 1. BWB_SITE_CNT is the number of sites that exists. By default this is 1. SESSION_SAVE_PATH is duplicated here because when editing a site that is not active, it may be necessary to set the session_save_path to track which site is being edited in a session var. It will become problematic to get the SESSION_SAVE_PATH define from the default config.php file in connect/ because once that file is opened, opening the config.php file in connect2/ will not replace the defines without first un-defining those constants.

To setup a second site, the first step is to set BWB_SITE_CNT to 2. Then copy the connect/ folder to connect2/. Subsequent sites can be setup in a similar fashion, i.e. BWB_SITE_CNT = 3, copy the connect/ folder to connect3/ folder, etc.

Next you will need to copy your Breeze database and set a database user to new database copy. You can do this using phpMyAdmin and the database administration console inside of cPanel or whatever is provided for your hosting account. There are also command line methods to do this.

Next you will need to modify your db_connect.php and config.php files in the connect2/ folder. The db_connect.php file's contents are as follows:

<?php
$hostname = "localhost";
$bwb_database = "myhostinguser_cms";
$db_username = "myhostinguser_web";
$db_password = "**************";
$dsn = "mysql:host=" . $hostname . ";dbname=" . $bwb_database;

try {
$bwb_dbh = new PDO($dsn, $db_username, $db_password);
} catch (PDOException $e) {
echo 'We are sorry, we not able to connect right now. Please try again later: ' . $e->getMessage();
}
?>

If you reused the same user for your first site, then you will only need to change value for $bwb_database. If you created a new user and password then you have to update the values for $db_username and $db_password as well.

Then contents of the config.php file are as follows:

<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 2/6/2012 ELL
//

// Special note about changing folders from defaults: Paths to images, CSS or scripts might not translate 100% correctly for templates
// if you change from the default locations. This can be corrected by editing locations, although it could be quite tedious and not
// necessarily obvious to non-web developers. If you wish for your site to appear as your domain name without showing any folders in
// the address bar of the browser, you can set BWB_BASE_DIR and BWB_WEBPAGE_DIR to ''. All other folder defaults must have some
// non-empty name for the system to work properly.

// *** Site Base Folder ***
// Do not include leading or trailing slashes. For web root level leave empty.
// Examples:
// Webroot: ''
// Folder: 'mywebsitefolder'
// Nested folders: 'mywebsitefolder/mywebsitesubfolder'
define('BWB_BASE_DIR', '');

// *** Webpage Folder ***
// Leave empty for webroot, i.e. ''
define('BWB_WEBPAGE_DIR', '');

// *** Image Folder ***
// Cannot be empty.
define('BWB_IMAGE_DIR', 'images');

// *** CSS Folder ***
// Cannot be empty.
define('BWB_CSS_DIR', 'css');

// *** Flash Folder ***
// Cannot be empty.
define('BWB_FLASH_DIR', 'flash');

// *** Media Folder ***
// Cannot be empty.
define('BWB_MEDIA_DIR', 'media');

// *** Scripts Folder ***
// Cannot be empty.
define('BWB_SCRIPTS_DIR', 'scripts');

// *** Library Folder ***
// Cannot be empty.
define('BWB_LIB_DIR', 'php');

// *** Fonts Folder ***
// Cannot be empty.
define('BWB_FONTS_DIR', 'fonts');

// *** Table Prefix ***
// You may want to use a table prefix, especially if the Breeze Website Builder must share the same database as another application.
// Include an underscore if your table names will have a prefix with an underscore. This is more typical of table prefixes.
// i.e. 'BWB_'
define('BWB_TABLE_PREFIX', 'bwb_');

// *** Require SSL ***
// 0 = SSL not required
// 1 = SSL required.
// If set, going to http://mywebsite.com/manage will automatically forward to https://mywebsite.com/manage
define('BWB_REQUIRE_SSL', 1);

// *** Salt ***
// Random string to salt password. You may change this, BUT be logged in as an administrator. You will need to change
// all of your BWB passwords immediately upon uploading the new config file AND you won't be able to login to do this.
define('BWB_SALT', '*************************');

// *** Salt ***
// Random string to salt passwords used for required login pages on website. You may change this, BUT you will need to
// change all of your users' passwords immediately upon uploading the new config file. Your users will not be able to login
// until their passwords have been re-created.
define('BWB_PUB_SALT', '************************');

// *** S/N ***
// This site's Breeze Website Builder serial number
define('BWB_SN', 'Breeze Website Builder');

// *** Search Engine Friendly (SEF) URLs ***
// 0 = off
// 1 = on
// When on, menu generator produces links without .php. Need to uncomment lines in .htaccss file pertaining to mod rewrite.
define('SEF_URL', 0);

// *** Session Save Path ***
define('SESSION_SAVE_PATH', '/tmp');
// Session save path is not defined on all servers by default. Default path on most severs is /tmp, but you may need to change
// this path to a folder within your hosting account for example. Note: do not use trailing slash '/'.

// *** Language ***
define('BWB_LANG', 'en');
?
>

The defines or concern are the folder locations: BWB_BASE_DIR, BWB_WEBPAGE_DIR, BWB_IMAGE_DIR, BWB_CSS_DIR, BWB_FLASH_DIR, BWB_MEDIA_DIR, BWB_SCRIPS_DIR, BWB_LIB_DIR and BWB_FONTS_DIR. Most of the folders you do not need to change and in fact probably will not want to. The three folders you are most likely going to want to change are the BWB_WEBPAGE_DIR, the BWB_IMAGE_DIR and the BWB_CSS_DIR. It all depends are the degree of file reuse or isolation that you want. The BWB_CSS_DIR is the one define that should always be changed. This contains the style sheet for you site and if you don't create a new folder for your style sheets, you will most certainly be overwriting the styles sheets for all of your websites. So be sure to create a new folder, i.e. css2 or stylesheets or whatever and update BWB_CSS_DIR to reflect this.

It is also highly possible that you will want to create a new folder for the web pages themselves. You would then update BWB_WEBPAGE_DIR to reflect this. Note that this is not absolutely necessary because the page files will inherit the style sheets, the content and all individualized page settings of whatever site is active (or whatever site is being edited in the webmasters session). The only exceptions are what plugins that may be installed AND if these plugins include injected PHP code into the page file. Much of the time this code may be exactly the same such as in the case of a constant form page named "contact". But this is not a given, and if you want to re-use the webroot location for your pages for example, you need to be careful to use different page names if it is possible the plugin code may differ between different site versions. And of course if you have customized a page file (not recommended) this could also be an issue. But it is nice to have your web pages at webroot whenever possible, so it is worth considering not changing BWB_WEBPAGE_DIR. If you don't want to change the location of your page files, then you will need to change a site option to allow for creating pages even though the page file already exists. This is done under Change Site Options in the Breeze Website Builder™ as shown below:

How to handle page already exists error

By default, Disallow Creation of Page is set which throws an error and halts the process whenever a page file of the page that is being created is found. Obviously this would make it nearly impossible to reuse the same web page folder between sites. By selecting either of the other two options you will be able to proceed with creating same-name pages or your new site. You may select Keep Existing Page File and Continue to prevent overwriting the existing files. Normally this should be fine; however, if your page files were created in a Breeze version prior to 6.6.0, it will be necessary to overwrite the files with a newer version of the page-template layout file to take advantage of the ability to see the new site without it being active. To do this change the option to Overwrite Existing Page File and Continue.

The next most likely define you may want to change is BWB_IMAGE_DIR. This would prevent overwriting images of existing sites in the case of file-name collisions. It also reduces the number of images to sort through when setting up the new site. Be sure to actually create the new directories that you have updated your website folder defines to.

After the new site setup is complete, when you go to log into the Breeze you will see the new option on your login screen as shown below:

Login screen with multi-site selection

Simply select 2 or whatever your new site is and login as normal to edit the new site. Note that when you look at the website with the browser you logged into, it will be the site you are editing. If you want to view the site that is currently active, you will need to use another browser, i.e. Firefox instead of Chrome, or vice versa or Edge or Safari or Opera or whatever. When your new site is ready to launch, just change the value of BWB_ACTIVE_SITE to the number of your new site and you are done!