dynamic / silverstripe-elemental-blocks

Custom elements that work with SilverStripe Elemental module
BSD 3-Clause "New" or "Revised" License
8 stars 5 forks source link

Headlines for ElementAreas in CMS #36

Closed korthjp17 closed 6 years ago

korthjp17 commented 6 years ago

Hard to tell which area you are adding an element to unless you guess and test

mak001 commented 6 years ago

This can be fixed with something like

use DNADesign\Elemental\Models\ElementalArea;
use SilverStripe\Forms\FieldList;

class ElementPage extends \Page
{
    /**
     * @var array
     */
    private static $has_one = [
        'ElementalSidebar' => ElementalArea::class,
    ];
    /**
     * @var array
     */
    private static $owns = [
        'ElementalSidebar'
    ];

    /**
     * @return FieldList
     */
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        // sets the titles for the fields
        $fields->dataFieldByName('ElementalSidebar')->setTitle('Sidebar');
        $fields->dataFieldByName('ElementalArea')->setTitle('Main');
        return $fields;
    }
}

The titles for element area fields would have to be added on every page with multiple areas.