基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/umbraco/Umbraco-CMS-Backoffice-Skills --skill umbraco-tree-item命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Run tests from skill examples and generate a report (project)
Validate links and references in SKILL.md files using deterministic scripts
Umbraco backoffice extension customisation - complete working examples showing how extension types combine
| name | umbraco-tree-item |
| description | Implement tree items in Umbraco backoffice using official docs |
| version | 1.0.0 |
| location | managed |
| allowed-tools | Read, Write, Edit, WebFetch |
Tree Items define how entities are rendered in tree structures throughout the Umbraco backoffice. They control the visual representation and behavior of items in sidebars and navigation trees. Tree items are associated with entity types and can be customized to display additional information, icons, or custom rendering for specific entity types.
Always fetch the latest docs before implementing:
Most tree items use kind: 'default' and don't need a custom context. Only create a custom context for:
If you just need standard tree items, use kind: 'default' without a custom context.
Tree: Tree items work within tree structures
umbraco-treeRepository Pattern: When loading tree data
umbraco-repository-patternContext API: When accessing tree context
umbraco-context-apiexport const manifests: Array<UmbExtensionManifest> = [
{
type: 'treeItem',
kind: 'default',
alias: 'My.TreeItem',
name: 'My Tree Item',
forEntityTypes: ['my-entity-type'],
},
];
import { MY_ENTITY_TYPE, MY_ROOT_ENTITY_TYPE } from '../entity.js';
export const manifests: Array<UmbExtensionManifest> = [
{
type: 'treeItem',
kind: 'default',
alias: 'My.TreeItem.Custom',
name: 'My Custom Tree Item',
forEntityTypes: [MY_ENTITY_TYPE, MY_ROOT_ENTITY_TYPE],
api: () => import('./my-tree-item.context.js'),
},
];
import { UmbDefaultTreeItemContext } from '@umbraco-cms/backoffice/tree';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbTreeItemModel, UmbTreeRootModel } from '@umbraco-cms/backoffice/tree';
export class MyTreeItemContext extends UmbDefaultTreeItemContext<
UmbTreeItemModel,
UmbTreeRootModel
> {
constructor(host: UmbControllerHost) {
super(host);
}
// Override to customize icon
override async getIcon() {
const item = this.getTreeItem();
if (item?.hasChildren) {
return 'icon-folder';
}
return 'icon-document';
}
// Override to add custom labels/badges
override async getLabel() {
const item = this.getTreeItem();
item?. ?? ;
}
}
{ api };
import { MY_ENTITY_TYPE, MY_ROOT_ENTITY_TYPE } from './entity.js';
import { MY_TREE_ALIAS, MY_TREE_REPOSITORY_ALIAS } from './constants.js';
export const manifests: Array<UmbExtensionManifest> = [
// Tree definition
{
type: 'tree',
kind: 'default',
alias: MY_TREE_ALIAS,
name: 'My Tree',
meta: {
repositoryAlias: MY_TREE_REPOSITORY_ALIAS,
},
},
// Tree item for the entities
{
type: 'treeItem',
kind: 'default',
alias: 'My.TreeItem',
name: 'My Tree Item',
forEntityTypes: [MY_ROOT_ENTITY_TYPE, MY_ENTITY_TYPE],
},
];
interface ManifestTreeItem extends ManifestElementAndApi<UmbControllerHostElement, UmbTreeItemContext> {
type: 'treeItem';
forEntityTypes: Array<string>; // Entity types this tree item renders
}
Built-in entity types that have tree items:
document - Content nodesdocument-root - Content rootmedia - Media itemsmedia-root - Media rootmember - Membersdata-type - Data typesdocument-type - Document typestemplate - TemplatesThe kind: 'default' uses the standard tree item rendering. Custom kinds can be created for specialized rendering.
That's it! Always fetch fresh docs, keep examples minimal, generate complete working code.