DNADesign\Elemental\Extensions\ElementalAreasExtension
This extension handles most of the relationships between pages and element area, it doesn't add an ElementArea to the page however. Because of this, developers can add multiple {@link ElementArea} areas to to a page.
If you want multiple ElementalAreas add them as has_ones, add this extensions
and MAKE SURE you don't forget to add ElementAreas to $owns, otherwise they
will never publish
private static $has_one = array(
'ElementalArea1' => ElementalArea::class,
'ElementalArea2' => ElementalArea::class
);
private static $owns = array(
'ElementalArea1',
'ElementalArea2'
);
private static $cascade_duplicates = array(
'ElementalArea1',
'ElementalArea2'
);
Synopsis
class ElementalAreasExtension
extends DataExtension
{
- // members
- private static array $ignored_classes = ;
- private static boolean $clear_contentfield = false;
- private static boolean $sort_types_alphabetically = true;
- private static boolean $keep_content_fields = false;
- // methods
- public array getElementalTypes()
- public array getElementalRelations()
- public void updateCMSFields()
- public void onBeforeWrite()
- public boolean supportsElemental()
- public DataObject ensureElementalAreasExist()
- public void requireDefaultRecords()
Hierarchy
Extends
- SilverStripe\ORM\DataExtension
Uses
- SilverStripe\Core\Extensible
Members
private
- $clear_contentfield
—
boolean
On saving the element area, should Elemental reset the main website `$Content` field. - $ignored_classes
—
array
Classes to ignore adding elements to - $keep_content_fields
—
boolean
Whether or not to replace the default SiteTree content field Applies globally, across all page types; unless a page type overrides this with its own config setting of `elemental_keep_content_field` - $sort_types_alphabetically
—
boolean
Whether to sort the elements alphabetically by their title
Methods
public
- ensureElementalAreasExist() — Set all has_one relationships to an ElementalArea to a valid ID if they're unset
- getElementalRelations() — Returns an array of the relation names to ElementAreas. Ignores any has_one fields named `Parent` as that would indicate that this is child of an existing area
- getElementalTypes() — Get the available element types for this page type,
- onBeforeWrite() — Make sure there is always an ElementalArea for adding Elements
- requireDefaultRecords() — Extension hook {@see DataObject::requireDefaultRecords}
- supportsElemental()
- updateCMSFields() — Setup the CMS Fields