TestExtensionA
adds a field named “Test A”, TestExtensionB
adds a field named “Test B”.
class TestExtensionA extends Extension {
public function updateCMSFields(FieldList $fields) {
$fields->push(TextField::create('TestA', 'Test A'));
}
}
class TestExtensionB extends Extension {
public function updateCMSFields(FieldList $fields) {
$fields->push(TextField::create('TestB', 'Test B'));
}
}
With this configuration “Test B” would appear before “Test A”, despite being set after it in config. This example is easily fixed - you can either reverse the order, or merge the two config “blocks”. However if you are trying to control whether your extension is included before/after another module, you don’t have this control.
---
Name: 'block1'
---
Page:
extensions:
- TestExtensionA
---
Name: 'block2'
---
Page:
extensions:
- TestExtensionB
With this configuration “Test A” would appear before “Test B”. The After: '#block2'
is slightly misleading - it means that block1
will be merged into the config system after block2
. Think of it as “last in, first out” in this example - TestExtensionA
was merged in last, so will be triggered first.
---
Name: 'block1'
After: '#block2'
---
Page:
extensions:
- TestExtensionA
---
Name: 'block2'
---
Page:
extensions:
- TestExtensionB