stnvh/silverstripe-infoboxes

Conditional CMS info boxes.

Installs: 2 195

Dependents: 1

Suggesters: 0

Security: 0

Stars: 9

Watchers: 3

Forks: 2

Open Issues: 4

Type:silverstripe-module

1.2.1 2014-12-05 11:48 UTC

This package is not auto-updated.

Last update: 2024-03-11 23:45:11 UTC


README

Build Status Latest Stable Version License

Conditional CMS info boxes.

Info Boxes

By Stan Hutcheon - Bigfork Ltd

Installation:

Composer:

composer require stnvh/silverstripe-infoboxes ~1

Download:

Clone this repo into a folder called infoboxes in your silverstripe installation folder.

Usage:

It currently has 5 built in checks:

  • Dev mode
  • Favicon existance
  • Google analytics code
  • Default password
  • if www is used

To add a check, create a file in /mysite/code/ called InfoBox_[your_check_name].php with the following functions:

example:

<?php

class InfoBox_example implements InfoBox {

	public function show() {
        return Director::isLive(); // Our conditional code, this can be anything as long as it returns true or false
	}

	public function message() {
		return 'Live Mode'; // Message to be displayed
	}

	public function severity() {
		return 2; // 0 = severe, 1 = warning, 2 = info
	}

	public function link() {
		// Can be any internal or external URL, or false if none
		return 'http://doc.silverstripe.org/framework/en/topics/debugging/#environment-types';
	}
    
}

You can now programmatically disable specific checks via the config API. Either via config.yml:

InfoBoxes:
  disabled:
    - example
    - dev
    - www

or via _config.php:

<?php

InfoBoxes::set_disabled('example');
// or
InfoBoxes::set_disabled(array('www', 'dev'));

You can either use the concatenated classname (e.g InfoBox_www -> www) or the full class name.

After installing via composer, or after adding a new InfoBox, you must /dev/build