A basic item handling permissions for elemental blocks with children
This module adds a blank base item which you can use to add sub-items to elements
and a gridfield config which mimics the parent ElementalArea feel for these Items,
allowing an editor to handle these "blocks" like elements.
This module is best used when the goal is to create an element which acts as a
holder for some content "blocks". These blocks might for example be cards,
images in a gallery or slides in a carousel.
composer require syntro/silverstripe-elemental-baseitem
See License
First, simply extend the base item:
use Syntro\SilverStripeElementalBaseitem\Model\BaseItem;
class Teaser extends BaseItem
{
private static $displays_title_in_template = true;
private static $db = [
// Whatever you need for the item to render
];
private static $has_one = [
'Section' => TeaserCardsBlock::class,
];
}
By default, the baseItem has a Title
and a ShowTitle
field, similar to the
BaseElement in elemental. They will also use the title composite field from the
silverstripe-elemental module. This behaviour can be disabled by setting
displays_title_in_template
to false in yaml config or directly in the class.
Then, add the relation to the desired element and configure the gridfield:
use DNADesign\Elemental\Models\BaseElement;
use Syntro\SilverStripeElementalBaseitem\Forms\GridFieldConfig_ElementalChildren;
class TeaserCardsBlock extends BaseElement
{
private static $has_many = [
'Teasers' => Teaser::class
];
/**
* @return FieldList
*/
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function ($fields) {
if ($this->ID) {
/** @var GridField $griditems */
$griditems = $fields->fieldByName('Root.Teasers.Teasers');
$griditems->setConfig(GridFieldConfig_ElementalChildren::create());
}
});
return parent::getCMSFields();
}
}
Bugs are tracked in the issues section of this repository. Before submitting an issue please read over
existing issues to ensure yours is unique.
If the issue does look like a new bug:
Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.
If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem