POC DO NOT MERGE - Make CMSMain work with other models #2939
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proof of concept as part of #2933 to see what's needed to make
CMSMain
work with classes that aren'tSiteTree
.To play around with this, install silverstripe/taxonomy and add the following YAML config to your project:
Your
/admin/pages
will now be working with taxonomy terms, rather than pages.Theoretically this could work with any
DataObject
class which hasCMSEditLinkExtension
andHierarchy
applied.What would still need to be done besides this
CMSPagesController
,CMSPageEditController
,CMSPageSettingsController
,CMSPageHistoryViewerController
, andCMSPageAddController
so you could have multiple instances of this going at once, e.g. one admin for pages, one for taxonomies, etc - without having to subclass all of these controllers as well.LeftAndMain
at all - either this could all be handled in the mainHierarchyModelAdmin
class (see below) or these could all be more generic controllers.CMSMain
, but instead get any information they need by calling methods onCMSMain
(i.e. have theCMSMain
instance passed to their constructor) or having that information passed through to them via setters or via their constructor.HierarchyModelAdmin
(which would belong insilverstripe/admin
along with all appropriate JS), and haveCMSMain
be a subclass ofHierarchyModelAdmin
with itstree_class
set toSiteTree
ModelAdmin
and this new class.SiteTree
andCMSMain
. These should go into a new class (probably an extension) that can be applied to any classes that want to live in this admin type. Things like tree title vs menu title vs title, icon, status flags, tree node classes, etcHierarchy
,CMSPageEditController
, and this new extension. But that also means you can just apply 3 extensions to any model and boom, you're ready to go.invokeWithExtensions
(or just ahasMethod()
check) to allow the model to update itVersioned
is applied and probably also have other assumptions that make them not workCMSMain
is just completely incompatible with these changes. It has a hardcoded form, and a different code path for the actual search functionality. We should marry up the wayGridFieldFilterHeader
and the filter/search in here work.GridFieldFilterHeader
logicCMSMain::getSearchForm()
get moved intoSiteTree::searchableFields()
SiteTree
gets a customSearchContext
subclass which leveragesCMSSiteTreeFilter
for the field that uses it (if that's necessary - I haven't looked too deep into the search code path for sitetree)SiteTree
and handle making it work as a separate effort.Stretch goal
Make this handle multiple classes in separate tabs, like
ModelAdmin
does via itsmanaged_models
config. Then you could still have a single "Taxonomies" CMS section, but it could handle bothTaxonomyTerm
andTaxonomyType
with this hierarchical style.Note that
TaxonomyType
isn't hierarchical - so either we'd need to change that, or better yet AAALLL of this logic could just get bundled together withModelAdmin
, so you can have for example one tab for managingTaxonomyTerm
which uses the tree structure, and one tab for managingTaxonomyType
which uses the normalModelAdmin
grid structure.