Skip to content
Cloudmanic Labs, LLC edited this page Aug 2, 2014 · 8 revisions

Most of the configuration for Cloudmanic CMS is done via the Config table. However there are a few configs that must be made before loading the database. Typically these are just database related configurations.

If you marry your CMS with a framework you really do not need to configure anything extra. If you do not marry with a framework or you want to override the framework settings you can pass in a configuration file.

Here are instructions on how to build your own config file.

  1. Somewhere out of the document root create a file and name it as you wish. For this example we will call it cms.php. In that file add the following.
<?php
return array(
	// Core CMS Configs.
	'site_name' => 'My CMS',
	'assets_base' => CMS::base_url() . 'assets',
        'public_base' => (CMS::get_env() == 'local') ? 'http://localhost/' : 'http://example.org/',
	'cp_base' => '',
	'cp_base_seg' => 1, 
	'cp_force_ssl' => FALSE,
	'cp_login_type' => 'default',
	'cp_home' => 'blocks',
	'cp_tmp_dir' => '/tmp', // no trailing slash.
	'cp_thumb_width' => '300',
	'cp_thumb_height' => '300',
	'cp_clear_ci_page_cache' => TRUE,
	'app-header-head' => '',
	'app-footer-body' => '',
	'app-header-files' => [],
	'app-footer-files' => [],
        'edit-continue-button' => 'Save_And_Continue_Editing', // Save_And_Continue or Save_And_Continue_Editing or leave blank
	'status-default' => 'Active',
	'status-options' => [
		'Active' => 'Active', 
		'Disabled' => 'Disabled'
	],	

	// Uploading media.
	'cp_media_driver' => 'local-files', // local-files / amazon-web-services-s3 / rackspace-cloud-files,
	'cp_media_file_types' => 'gif|jpg|jpeg|png|pdf|mov|avi|mp4',
	'cp_media_file_max_size' => 102400, // kilobytes
	'cp_image_resize' => '1200',

	// Local file config.
	'cp_media_local_path' => 'uploads/',
	'cp_media_local_dir' => 'uploads/', // must be from document root
	'cp_media_local_url' => CMS::base_url(), 
	'cp_media_local_ssl_url' => CMS::base_url(), 

	// Amazon config
	'cp_media_amazon_s3_access_key' => '',
	'cp_media_amazon_s3_secret_key' => '',
	'cp_media_amazon_s3_container' => '',
	'cp_media_amazon_s3_path' => 'cms/',
	'cp_media_amazon_s3_url' => '', // trailing slash
	'cp_media_amazon_s3_ssl_url' => '', // trailing slash

	// Rackspace config	
	'cp_media_rackspace_username' => '',
	'cp_media_rackspace_key' => '',
	'cp_media_rackspace_container' => '',
	'cp_media_rackspace_path' => 'cms/',
	'cp_media_rackspace_url' => '',
	'cp_media_rackspace_ssl_url' => ''
);  

You can also add just the settings you want to override. Also, if you want to override the other settings that live in the database you can do that here as well.

The key is make sure you have your database settings somewhere. Either via a framework or here.

  1. Make your index.php file look like the following.
require '../../vendor/autoload.php';

CMS::config_file('../../cms.php');
CMS::framework('laravel3', '../../application');
require CMS::boostrap('../../vendor');

So this will set an external config file called cms.php. It will also connect with the laravel3 framework. The system will look at laravel3 for configuration information. Then it will look at the config file (notice the order you call these things does not matter). The external file you include will override any settings from laravel3.

Please note you do not need to include a framework. You can just include the config file. Just need to include one or the other (or both).

Migrating Configs - Loading Exported Configs

Sometimes we want to export the configurations we set within the CMS (ie. Navigation, Buckets, Relationships, and more). Within in the CMS if you navigate to http://path-to-your-cp.com/admin/export/configs you will get a dump of the configurations.

If you look closely at the dump you will see a variable called "hash". This is a md5 hash of the database state, (md5 hash of the entire configurations DB as a JSON file). When we import a configuration set we check the CMS_State table. If the hash in that table (name: import-hash) does not match we import the configuration. If it does we simply do nothing.

Please note that if you have any setting that have not been exported they will be overwritten.

To make the CMS check the exported config on every page load we do the following.

  1. Create a file and dump the exported data into it like so.
<?php

return 'PUT JSON EXPORTED CONFIG DATA HERE';
  1. Then in your index.php for the CMS add call the CMS::load_configuration_from_export('path to file') command. For example your config file might looks something like this.
<?php
require '../../vendor/autoload.php';

CMS::framework('laravel3', '../../application');
CMS::config_file('cms.php');
CMS::load_default_blocks('./blocks.php');
CMS::load_configuration_from_export('./config.php');
require CMS::boostrap('../../vendor');
Clone this wiki locally