Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using >1 ElementalArea confuses content authors #758

Open
phptek opened this issue Nov 28, 2019 · 5 comments
Open

Using >1 ElementalArea confuses content authors #758

phptek opened this issue Nov 28, 2019 · 5 comments

Comments

@phptek
Copy link

phptek commented Nov 28, 2019

For projects that have migrated to Elemental from other Blocks modules, CMS authors are used to seeing at-a-glance, which "Area" within a page, their block will be added to.

OOTB, I see no easy way to prepend a HeadingField or something similar before each ElementalArea - in fact, AFAICT, the standard Silverstripe forms API doesn't work as expected: If I try to use $fields->insertBefore() in an additional DataExtension subclass, the headings are added, but in a completely different spot in the CMS' UI.

I had to resort to the folowing hackery to make it work (Unless of course I am missing something)

1). Subclass ElementalPageExtension (Which itself subclasses ElementalAreasExtension)
2). Overlload updateCMSFields() and lightly modify as per the following:

$label = sprintf('%s Blocks', ucwords(FormField::name_to_label(str_replace('ID', '', $key))));
$heading = NoticeMessage::create($label, "Area_{$key}");

if ($this->owner instanceof SiteTree && $fields->findOrMakeTab('Root.Main')->fieldByName('Metadata')) {
    $fields->addFieldsToTab('Root.Main', [$heading, $editor], 'Metadata');
} else {
    $fields->addFieldsToTab('Root.Main', [$heading, $editor]);
}

This shouldn't be too hard to configure as an opt-in using the Config system - that is as I said, unless I'm missing something.

@brynwhyman
Copy link

Do you mean like this?

image

You can see the above implementation in the Silverstripe demo

Codebase is here: silverstripe/bambusa-installer

@phptek
Copy link
Author

phptek commented Dec 12, 2019

Yeah, like that but make it OOTB functionality, part of the Elemental / SIlverstripe forms API.

Cheers!

@mfendeksilverstripe
Copy link
Contributor

I recommend to avoid having multiple elemental areas on a page. See #759 for more details.

@michalkleiner
Copy link
Contributor

I'd support making the heading part of the area, being optional.

@tractorcow
Copy link
Contributor

tractorcow commented Jul 1, 2020

My solution is to just use ElementalAreasExtension directly, and not the pages specific one, and then add the block headers manually.

same as the demo solution actually.

$fields->insertBefore('HeaderArea', HeaderField::create('HeaderAreaTitle', 'Page heading blocks'));
$fields->insertBefore('BodyArea', HeaderField::create('BodyAreaTitle', 'Main content blocks'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants