Content pages based on data objects for better content structure
- Supports draft/publish state
- Drag n drop reordering
- Copy & Paste
- Black/white listing of block types
- Same content element on different pages
Silverstripe Blocks has more features like block sets, forms ,... But the ui of Flexible-Content is more simple and easier to understand and use for non technical users.
composer require nblum/silverstripe-flexible-content
For a basic set of content element you may install the elements-package:
composer require nblum/silverstripe-flexible-content-elements
- Create a page template
ContentPage
in your theme and add$FlexibleContent
- Run
dev/build?flush=1
- Change the Page type to "Content Page" of every page you like
Edit your config.yml file and add the following lines. This is the default config and only necessary if changes are neede
FlexibleContent:
availableContentElements:
false
forbiddenContentElements:
- ContentElement
Create a class which extends the ContentElement class or any other existing content element.
<?php
class MyTextContentElement extends \TextContentElement
{
private static $db = array(
'Splitview' => 'Boolean'
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$field = new CheckboxField('MyCheckbox', 'a checkbox');
$fields->addFieldToTab('Root.Main', $field);
return $fields;
}
}
And provide a include template file with the same name
<div <%if $Splitview %> class="splitview" <% end_if %>
$Content
</div>
For more examples have a look at the elements-package