Open sunnysideup opened 6 years ago
Could you clarify what you're suggesting here?
Are you suggesting we deprecate CMSMain::PageTypes
and encourage people to use SiteTree::getClassDropdown
instead?
Here are the links:
CMSMain::PageTypes
https://github.com/silverstripe/silverstripe-cms/blob/4/code/Controllers/CMSMain.php#L1107-L1137
Gets data from SiteTree::page_type_classes
and removes:
$this->can($needPermissions) != true
... needsPermission comes from specific Page Type
Sorts by i18n_singular_name
returns SS_List of items with a bunch of entries.
Also not that there is a function getPageTypes in CMSMain: https://github.com/silverstripe/silverstripe-cms/blob/4/code/Controllers/CMSMain.php#L955-L963 That does something completely different ... I will create a separate ticket for that.
SiteTree::getClassDropdown
https://github.com/silverstripe/silverstripe-cms/blob/4/code/Model/SiteTree.php#L2485-L2534
gets data from SiteTree::page_type_classes
and removes:
$this->can($needPermissions) != true
... needsPermission comes from specific Page Type
Sorts by i18n_singular_name
RELATIVE TO CONTEXT ... this means relative to the parent page.https://github.com/silverstripe/silverstripe-cms/blob/4/code/Controllers/CMSMain.php#L955-L963
SiteTree::page_type_classes
https://github.com/silverstripe/silverstripe-cms/blob/4/code/Model/SiteTree.php#L470-L506
Takes all site tree descendants (class X extends SiteTree) and removes the ones marked in hide_ancestor
What I am suggesting is that CMSMain::PageTypes
uses SiteTree::getClassDropdown
rather than repeating its code and that we add a param to SiteTree::getClassDropdown
where the context can be set (with the ability to set it to null). Or something like this. The reason I am suggesting this is so that we have one source for the list of page types.
consider using SiteTree::getClassDropdown instead of SiteTree::page_type_classes in CMSMain::PageTypes as getClassDropdown and PageTypes almost does the same thing, but providing the final data from SiteTree rather than CMSMain seems better.