Skip to content
A SilverStripe module for creating templates within the CMS that can override those defined in the theme, for both Layout and main templates
PHP Scheme
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_config
client/images
src
tests
.gitattributes
.gitignore
.travis.yml
.upgrade.yml
CHANGELOG
README.md
composer.json

README.md

UserTemplates

Allows cms users to apply templates that are created and defined within the CMS directly, including CSS and JavaScript files, to trees of content.

Getting started

Add the following to your Page_Controller class:

public function getViewer($action) {
    $viewer = parent::getViewer($action);

	$this->extend('updateViewer', $action, $viewer);

    return $viewer;
}

Add configuration to bind the extension into place

SilverStripe\CMS\Model\SiteTree:
  extensions: 
    - Symbiote\UserTemplates\UserTemplatesExtension
PageController:
  extensions:
    - Symbiote\UserTemplates\UserTemplatesControllerExtension

Usage

Create a new template from the admin/templates section.

The Use of the template indicates whether it will be applied as a 'main' template or just the 'Layout' of the page.

The Content field should be defined as per a normal SilverStripe template

Any CSS or JS files uploaded will be included using Requirements:: calls

On a page, navigate to the Settings -> Theme tab. Select the relevant template to use.

If "Inherit" is set, then any parent page with a custom template defined will be used.

Templated elements

You'll need to add a custom ElementArea.ss template to your theme (on the path themes/your-theme/templates/DNADesign/Elemental/Models/ElementalArea.ss) that contains something similar to the following

<% if $ElementControllers.count > 0 %>
    <% loop $ElementControllers %>
        <div class="ElementAreaElement <% if Last %>ElementAreaElement--Last<% end_if %>">
            <% if $isTemplated %>
            $TemplatedContent
            <% else %>
            $Me
            <% end_if %>
        </div>
    <% end_loop %>
<% end_if %>


to make use of it.

Then, bind the extensions

---
Name: element_config
---
DNADesign\Elemental\Models\BaseElement:
  extensions:
    - Symbiote\UserTemplates\TemplatedElementExtension

DNADesign\Elemental\Controllers\ElementController:
  extensions:
    - Symbiote\UserTemplates\TemplatedElementControllerExtension

Credits

Icon via https://icons8.com/license/

You can’t perform that action at this time.