Skip to content

Commit

Permalink
DOC Document changes to CMSMain and LeftAndMain
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Dec 10, 2024
1 parent e168fc7 commit f5033f8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MySettingsAdmin extends SingleRecordAdmin

This admin section will fetch a record of the `MySettingsModel` class using the [`get_one()`](api:SilverStripe\ORM\DataObject::get_one()) method.

If you don't want the admin section to fetch your record in this way, you can set the [`restrict_to_single_record`](api:SilverStripe\Admin\SingleRecordAdmin->restrict_to_single_record) configuration property to false. In this case you must provide another way for the admin section to know which record to edit. This could be in the form of a separate action on the controller (e.g. `edit/$ID`), or by calling [`setCurrentPageID()`](api:SilverStripe\Admin\LeftAndMain::setCurrentPageID()) in the [`init()`](api:SilverStripe\Admin\LeftAndMain::init()) method of the controller.
If you don't want the admin section to fetch your record in this way, you can set the [`restrict_to_single_record`](api:SilverStripe\Admin\SingleRecordAdmin->restrict_to_single_record) configuration property to false. In this case you must provide another way for the admin section to know which record to edit. This could be in the form of a separate action on the controller (e.g. `edit/$ID`), or by calling [`setCurrentRecordID()`](api:SilverStripe\Admin\LeftAndMain::setCurrentRecordID()) in the [`init()`](api:SilverStripe\Admin\LeftAndMain::init()) method of the controller.

If there's no record to edit, by default it will create one for you. To disable that behaviour, set the [`allow_new_record`](api:SilverStripe\Admin\SingleRecordAdmin->allow_new_record) configuration property to false.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class MyAdmin extends LeftAndMain
```ss
<%-- MyRecordInfo.ss --%>
<div data-pjax-fragment="MyRecordInfo">
Current Record: $currentPage.Title
Current Record: $currentRecord.Title
</div>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ by the [jstree](https://jstree.com) library. It is configured through
`client/src/legacy/LeftAndMain.Tree.js` in the `silverstripe/admin` module, as well as some
HTML5 metadata generated on its container (see the `data-hints` attribute).

The tree is rendered through [LeftAndMain::getSiteTreeFor()](api:SilverStripe\Admin\LeftAndMain::getSiteTreeFor()),
The tree is rendered through [LeftAndMain::getTreeFor()](api:SilverStripe\Admin\LeftAndMain::getTreeFor()),
which recursively collects all nodes based on various filtering criteria.
The node strictly just has to implement the [Hierarchy](api:SilverStripe\ORM\Hierarchy\Hierarchy) extension,
but in the CMS usually is a [SiteTree](api:SilverStripe\CMS\Model\SiteTree) object.
Expand All @@ -36,7 +36,7 @@ code like this:
<ins class="jstree-checkbox">&nbsp;</ins>
<ins class="jstree-icon">&nbsp;</ins>
<span class="text">
<span class="jstree-pageicon"></span>
<span class="jstree-recordicon"></span>
<span class="item" title="Deleted">New Page</span>
<span class="badge deletedonlive">Deleted</span>
</span>
Expand Down Expand Up @@ -65,7 +65,7 @@ use Page;

class HomePage extends Page
{
private static $icon_class = 'font-icon-p-home';
private static $cms_icon_class = 'font-icon-p-home';

// ...
}
Expand Down
4 changes: 3 additions & 1 deletion en/08_Changelogs/6.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,9 @@ As a result of these changes, the following classes have had their class hierarc
|[`SubsiteXHRController`](api:SilverStripe\Subsites\Controller\SubsiteXHRController)|`LeftAndMain`|`AdminController`|
|[`CMSExternalLinksController`](api:SilverStripe\ExternalLinks\Controllers\CMSExternalLinksController)|`Controller`|`AdminController`|

The `tree_class` configuration property on `LeftAndMain` and its subclasses has be renamed to [`model_class`](api:SilverStripe\Admin\LeftAndMain->model_class). This is used in methods like [`getRecord()`](api:SilverStripe\Admin\LeftAndMain::getRecord()) to get a record of the correct class.
The `tree_class` configuration property on `LeftAndMain` and its subclasses has be renamed to [`model_class`](api:SilverStripe\Admin\LeftAndMain->model_class), and a new [`getModelClass()`](api:SilverStripe\Admin\LeftAndMain::getModelClass()) method has been implemented to return it. This is used in methods like [`getRecord()`](api:SilverStripe\Admin\LeftAndMain::getRecord()) to get a record of the correct class.

The `getModelClass()` method is the same method used in `ModelAdmin` to get the class for the currently accessed tab. This parity means you can predictably call `getModelClass()` on any initialised subclass of `LeftAndMain` and get an appropriate base class to work with.

#### Effects of this refactor in other classes

Expand Down

0 comments on commit f5033f8

Please sign in to comment.