Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Is your Backoffice a bit untidy?
- Member Types
- Data Types

## Installation

### Install Package

```powershell
dotnet add package Umbraco.Community.BackOfficeOrganiser
```

## Quick Start

- Go to the backoffice
Expand Down
8 changes: 8 additions & 0 deletions docs/README_nuget.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ Is your Backoffice a bit untidy?
- Member Types
- Data Types

## Installation

### Install Package

```powershell
dotnet add package Umbraco.Community.BackOfficeOrganiser
```

## Quick Start

- Go to the backoffice
Expand Down
59 changes: 59 additions & 0 deletions docs/extending/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Extending

You can implement your own `Organise Action`, a method that determines where a type should be moved to. Implement the following interfaces:

- `Document Types` => `IContentTypeOrganiseAction`
- `Media Types` => `IMediaTypeOrganiseAction`
- `Member Types` => `IMemberTypeOrganiseAction`
- `Data Types` => `IDataTypeOrganiseAction`

### Example
```csharp title="ExampleContentTypeOrganiseAction.cs"
using jcdcdev.Umbraco.Core.Extensions;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;

namespace Umbraco.Community.BackOfficeOrganiser.Organisers.ContentTypes;

public class ExampleContentTypeOrganiseAction : IContentTypeOrganiseAction
{
// Handle all but container types (Folders)
public bool CanMove(IContentType contentType, IContentTypeService contentTypeService) => !contentType.IsContainer;

public void Move(IContentType contentType, IContentTypeService contentTypeService)
{
var folderId = -1;
var folderName = string.Empty;
var isComposition = contentTypeService.GetComposedOf(contentType.Id).Any();

if (contentType.AllowedTemplates?.Any() ?? false)
{
folderName = "Pages";
}
else if (isComposition)
{
folderName = "Compositions";
}
else if (contentType.IsElement)
{
folderName = "Element Types";
}

if (!folderName.IsNullOrWhiteSpace())
{
folderId = contentTypeService.GetOrCreateFolder(folderName).Id;
}

contentTypeService.Move(contentType, folderId);
}
}

public class Composer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
// Make sure you register your action BEFORE the default!
builder.ContentTypeOrganiseActions().Insert<ExampleContentTypeOrganiseAction>();
}
}
```