toastnz / blocks-layouts
Silverstripe content blocks module
Installs: 4 118
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- php: >=7.4
- axllent/silverstripe-form-fields: ^1.5
- composer/installers: *
- silverstripe/cms: ^4.3
- silverstripe/framework: ^4.3
- silverstripe/userforms: ^5.5
- symbiote/silverstripe-gridfieldextensions: ^3.1
- toastnz/linkable: ^2
- undefinedoffset/sortablegridfield: ^2.0.4
- dev-master
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1
- 2.0
- 1.1
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-m3.3
- dev-m3-3/firstblock/css
- dev-m2
- dev-m3.2
- dev-temp/m3.2
- dev-m3.1
- dev-pre-m3
- dev-m1-ss5
- dev-m1
- dev-m3
- dev-ss5
- dev-feature/2023/marmalade2
This package is auto-updated.
Last update: 2024-11-25 20:47:58 UTC
README
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
Add / remove available alternate block layouts
"layout_src": directory that holds folders of different layouts with .ss templates "layout_icon_src": directory that holds all the layout icons "layout_dist_dir": specificed the css for block layouts
CSS file will only be included with the syntax of 'theme/themename/dist/styles/$LayoutName-$BlockType.css"
Toast\Blocks\Extensions\PageExtension: layout_src: 'app/templates/Toast/Blocks' layout_icon_src: 'app/client/images/layout-icons' layout_dist_dir: 'theme/themename/dist/styles'
Ensure there are at least one CustomBlock.ss and 'customblock.svg' icon in each of the specified directory. Layout will be available for all subsites.
.ss template naming
You may have multiple layouts, please ensure you have the block.ss created under a new layout folder in the src directory.
e.g. 'app/templates/Toast/Blocks/CustomLayoutNameOne/ImageBlock.ss'
or 'app/templates/Toast/Blocks/CustomLayoutNameTwo/ImageBlock.ss'
Layout icon naming:
Please ensure the layout icon are named after the block name are all in lowercase, e.g. customblock.svg.
e.g. 'app/client/images/layout-icons/customlayoutone/customblock.svg'
or 'app/templates/Toast/Blocks/customlayouttwo/customblock.svg'
Icon extensions
Allowed extension: 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg'
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