Download the PHP package sheadawson/silverstripe-blocks without Composer
On this page you can find all versions of the php package sheadawson/silverstripe-blocks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sheadawson/silverstripe-blocks
More information about sheadawson/silverstripe-blocks
Files in sheadawson/silverstripe-blocks
Package silverstripe-blocks
Short Description An alternative to the SilverStripe Widgets module.
License
Homepage http://github.com/sheadawson/silverstripe-blocks
Informations about the package silverstripe-blocks
SilverStripe Blocks
The Blocks modules aims to provide developers with a flexible foundation for defining reusable blocks of content or widgets that can be managed in the CMS.
Notice
This module is no longer maintained. If you would like to adopt it and give it a good home please submit your interest and I will be happy to discuss.
Features
- Blocks are Versioned
- Blocks with Forms possible (through
BlockController
) - Drag and Drop re-ordering of Blocks
- Duplicate Blocks
- BlockSets for global blocks
- Allow exclusion of any page types from using Blocks
- Allow disabling of default/example block type - ContentBlock
- Allow disabling of specific blocks
Upgrading from 0.x
See the upgrade guide
Requirements
- SilverStripe CMS ^4.0
- GridFieldExtensions
- MultivalueField
- GridField BetterButtons
Recommended
- GridField Copybutton (duplication of blocks, from BlockAdmin)
- GridField Sitetree Buttons (Edit pages directly from a Block's 'used on page' list)
Installation
Install via composer, run dev/build
Quickstart
1. Define Block Areas and Settings for your project in mysite/_config/config.yml
Remember to run ?flush=1
after modifying your .yml
config to make sure it gets applied.
2. Add Block Areas to your templates
Adding the BeforeContent
and AfterContent
blocks would look something like
$BlockArea(BeforeContent)
will loop over and display all blocks assigned to the BeforeContent
area on the current page
You can limit a block area to a maximum number of blocks using the second limit parameter
3. Add Blocks to a page in the CMS
You will now be able to add Blocks to Pages via the CMS page edit view and in the Blocks model admin. You can also define "BlockSets" in the Blocks model admin. BlockSets can be used to apply a common collection of blocks to pages that match the criteria you define on the set.
This module ships with a basic ContentBlock
, but this can be disabled through the `BlockManager::use_default_blocks config.
Help
Restrict Blocks to viewer groups or logged in users
When editing a block, you can restrict who can see it in the frontend by selecting "logged in users" or "users from these groups" under the Viewer Groups tab.
Templates
There are 2 types of templates you should be aware of.
BlockArea Template
The BlockArea
template is responsible for looping over and rendering all blocks in that area. You can override this by
creating a copy of the default BlockArea.ss
and placing it in your templates/Includes
folder.
It's likely that your block areas may require different templates. You can achieve this by creating a BlockArea_{AreaName}.ss
template.
Block Template
Each subclass of Block requires it's own template with the same name as the class. So, SlideshowBlock.php
would have a
SlideshowBlock.ss
template. If your block requires different templates depending on the BlockArea
it's in, you can
create SlideshowBlock_{AreaName}.ss
The current page scope can be accessed from Block templates with $CurrentPage
.
Block Area Preview
To aid website admins in identifying the areas they can apply blocks to, a "Preview Block Areas for this page" button
is available in the cms. This opens the frontend view of the page in a new tab with ?block_preview=1
.
In Block Preview mode, Block Areas in the template are highlighted and labeled.
There is some markup required in your BlockArea templates to facilitate this: The css class block-area
and the
data-areaid='$AreaID'
attribute.
Form Blocks
As of v1.0 Blocks can now handle forms. See this gist for as an example:
Remove the Blocks button from the main CMS menu
The BlockAdmin section is not always needed to be used. If you wish, you can remove the button from the menu by inserting this to mysite/_config.php
:
Block icons
Until this module properly supports icons, you can define icons by creating a getTypeForGridfield
method in your block.
Here's an example that uses font awesome:
Translatable Blocks
For creating Blocks with translatable content, using the translatble module, see this gist for a kick start.
Screenshots
Overview
Preview of block locations
Edit a block
Add an existing block
TODO
- [ ] Re-add: Sorting primarily by Area (in order of declaration in config), on Pages (removed in favor of dr'ndr sorting)
- [ ] Add icon/pic to base Block as method of recognition when dealing with lots of different blocks
All versions of silverstripe-blocks with dependencies
silverstripe/framework Version ~3.1
silverstripe/cms Version ~3.1
symbiote/silverstripe-gridfieldextensions Version ~2.0
symbiote/silverstripe-multivaluefield Version ~3.0
unclecheese/betterbuttons Version ~1.2