Skip to content

jcdcdev/Umbraco.Community.BackOfficeOrganiser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Umbraco.Community.BackOfficeOrganiser

Umbraco Marketplace GitHub License NuGet Downloads Project Website

Is your backoffice a bit untidy?

  • Single-click (and opinionated) organiser for
    • Document Types
    • Media Types
    • Member Types
    • Data Types
  • Automatically sorts on save (configurable)

A screenshot of the Back Office Organiser in action

Quick Start

  • Go to the backoffice
  • Click Settings
  • Click Organise
  • Select the types you wish to organise
  • Click submit and confirm
  • Refresh your page and enjoy a cleaner backoffice ✨

Configuration

Add the following to your appsettings.json file

{
  "BackOfficeOrganiser": {
    "DataTypes": {
      "InternalFolderName": "Internal",
      "ThirdPartyFolderName": "Third Party",
      "CustomFolderName": "Custom",
      "OrganiseOnSave": true
    },
    "ContentTypes": {
      "OrganiseOnSave": true
    },
    "MediaTypes": {
      "OrganiseOnSave": true
    },
    "MemberTypes": {
      "OrganiseOnSave": true
    }
  }
}

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

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>();
    }
}

Contributing

Contributions to this package are most welcome! Please read the Contributing Guidelines.

Acknowledgments (thanks!)