Skip to content

priscillay-toast/blocks

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SilverStripe Blocks

Simple content blocks system. Nothing fancy, easy to implement.

Requirements

See composer.json

Installation

Add the following to your config.yml (optional):

PageController:
  extensions:
    - Toast\Blocks\Extensions\PageControllerExtension

Use Page or other class that extends SiteTree.

In your Layout/Page.ss template, add the following:

<% loop $ContentBlocks %>
    $ForTemplate
<% end_loop %>

Configuration

Add / remove available block classes

Toast\Blocks\Extensions\PageExtension
  available_blocks:
    - Toast\Blocks\TextBlock

Create a custom block

Extend Block to create a new block type.

<?php
 

class MyBlock extends Toast\Blocks\Block
{
    private static $singular_name = 'My Block';
    private static $plural_name = 'My Blocks';
    private static $icon = 'mysite/images/blocks/custom.png';
    
    private static $db = [
        'Content' => 'HTMLText'
    ];

}

/themes/default/templates/Toast/Blocks/MyBlock.ss:

<%-- Your block template here --%>

<h2>$Title</h2>
$Content

Todo:

  • Template global providers
  • Zoning
  • Duplicate handlers
  • Tests
  • Through tables for more advanced versioning

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 84.2%
  • Scheme 15.8%