Retrieving the alias of a block in a custom property editor

Hello.

I have a custom property editor that I have added to Document Type called “Accordion”, with the alias of “accordion”.

I’ve added this document type as an available block on the “Blocks List” Data Type.

I need to somehow get the alias of the document type. In my case “accordion” inside of my custom property editor.

The reason I need to get this, is so that I can match the name of a specific alias/property elsewhere in my own configuration node.

Is this possible? I’ve tried all sorts of different contexts. I.e Block, Modal, Document, but cannot seem get hold of this alias. The closest I got was using the UMB_BLOCK_WORKSPACE_CONTEXT’s .getName() method, but this returns “‘block name content element type here…’”

Thank you in advance,
Rob

I once wrote a condition for a workspace view if it should be displayed or not, based on the content type alias (on in this case if the document implements a specific composition) of the current document. I think the logic will apply to you as well:

import { UMB_CONTENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/content';

/** 
 * Represents an Umbraco condition that checks if the current content implements the content expiration composition 
 */
export class ContentExpirationCondition extends UmbConditionBase<ContentExpirationConditionConfig> implements UmbExtensionCondition {
	constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<ContentExpirationConditionConfig>) {
		super(host, args);

		this.consumeContext(UMB_CONTENT_WORKSPACE_CONTEXT, (instance) => {
			this.observe(instance.structure.contentTypeAliases, (aliases) => {

				if (aliases.includes('expiringContent')) {
					this.permitted = true;
				} else {
					this.permitted = false;
				}
			});
		});
	}
}

Hey Luuk!

Thanks again for the quick reply!

I’ve tested out your logic, and it works great… but unfortunately not when the custom property editor exists on a document type that is added via a Block List.

It just doesn’t seem to run the following at all.

this.consumeContext(UMB_CONTENT_WORKSPACE_CONTEXT, (instance) => {
    console.log("Instance", instance);
    this.observe(instance.structure.contentTypeAliases, (aliases) => {
        console.log("Aliases", aliases);
    });
});

It’s given me an idea of where I would typically find the aliases for the document type, so that’s a step in the right direction for me.

I wonder if I am supposed to be able to consume the content workspace context from inside of the block list modal.

Thank you,
Rob