Skip to content

Commit

Permalink
Merge pull request #3 from adrexia/feature/silverstripe4
Browse files Browse the repository at this point in the history
FIX: Silverstripe 4 support
  • Loading branch information
adrexia authored Aug 24, 2017
2 parents fb3882f + eb7d43c commit 0190728
Show file tree
Hide file tree
Showing 17 changed files with 670 additions and 519 deletions.
54 changes: 29 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,65 @@

A module to assist with a website's basic branding. Allows setting of brand colours and fonts from within a Silverstripe Admin.


## Requirements

SilverStripe 3.3 or higher
SilverStripe 4 or higher. See 3.0 branch for SilverStripe 3 support

## Installation

``composer require adrexia/brand``

## Setup
Include the brand template in the head of you page template:
``<% include Brand %>``

By default this includes the fonts and the font-color. The Palette colours are for use on other page types, or for custom theming. For example, they can be used to add a restricted colourpalette to a page (with the help of the Color Palette module):
You can either just include the Favicons, and apply the colour schemes manually:
``<% include Adrexia/Brand/Favicons %>``

Or, include the brand template in the head of you page template to get both:
``<% include Adrexia/Brand/Brand %>``

$brand = Brand::get()->First();
By default this includes the fonts, the font-colors, and the favicons.
The Menu colours are left for you to implement, or disable based on your site's requirements.
The Palette colours are for use on other page types, or for custom theming. For example, they can be used to add a restricted colourpalette to a page (with the help of the Color Palette module):

if($brand) {
$fields->insertAfter(
ColorPaletteField::create(
"Color", "Color", $brand->getFullPalette()
), "Intro"
);
}
$brand = Brand::get()->First();

There is an extension 'BrandPageExtension' included for this purpose which adds a brand colour, a contrast colour, and an image. To enable it, add this to your _config.yml file:
if($brand) {
$fields->insertAfter(
ColorPaletteField::create(
"Color", "Color", $brand->getFullPalette()
), "Intro"
);
}

Page:
extensions:
- BrandExtension
There is an extension 'BrandDataObjectExtension' included for this purpose which adds a brand colour, a contrast colour, and an image. To enable it, add this to your _config.yml file:

Page:
extensions:
- Adrexia\Brand\BrandDataObjectExtension

The other variables provided can be called in a template with:
``$Brand.Logo``
``$Brand.BodyBackgroundColour``

To get the hex value of a colour from a colourpalette in your template you can do something like this:

<% if $Colour %>$Brand.getHex($Color)<% else %>$Brand.getHex($Level(1).Color)<% end_if %>
<% if $Colour %>$Brand.getHex($Color)<% else %>$Brand.getHex($Level(1).Color)<% end_if %>

## Subsite support
NOTE: Subsite support isn't yet complete for silverstripe 4

This module can work with subsites with the addition of the SubsiteModelExtension from adrexia/subsite-modeladmins (specifically, the onBeforeWrite and augmentSQL functions). You can install this via composer require, or just take the bits you need:

``composer require adrexia/subsite-modeladmins``

### Setup:
In your yml config:

Brand:
extensions:
- SubsiteModelExtension
BrandAdmin
extensions:
- SubsiteMenuExtension
Adrexia\Brand\Brand:
extensions:
- SubsiteModelExtension
Adrexia\Brand\BrandAdmin
extensions:
- SubsiteMenuExtension

The brand extension is supplied by the subsite modeladmin module. The BrandAdmin extension is straight from the subsites module, and enables the menu item in the CMS menu.

Expand Down
5 changes: 5 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

namespace Adrexia\Brand;



4 changes: 2 additions & 2 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Name: brand
---
SiteTree:
SilverStripe\CMS\Model\SiteTree:
extensions:
- BrandSiteTreeExtension
- Adrexia\Brand\BrandSiteTreeExtension
Loading

0 comments on commit 0190728

Please sign in to comment.