diff --git a/14/umbraco-cms/customizing/section-trees/sections/section-view.md b/14/umbraco-cms/customizing/section-trees/sections/section-view.md index d8f37c9a624..3b1d0d1ff90 100644 --- a/14/umbraco-cms/customizing/section-trees/sections/section-view.md +++ b/14/umbraco-cms/customizing/section-trees/sections/section-view.md @@ -12,17 +12,116 @@ This page is a work in progress and may undergo further revisions, updates, or a

Section View

-**Manifest** +## Creating a custom Section View + +In this section, you can learn how to register and create a custom Section View for the Umbraco backoffice. + +### Manifest + +The manifest file can be created using either JSON or Typescript. Both methods are shown below. + +{% tabs %} + +{% tab title="Json" %} + +We can create the manifest using json in the `umbraco-package.json`. ```json { "type": "sectionView", "alias": "My.SectionView", "name": "My Section View", + "element": "./my-section.element.js", "meta": { - "sections": ["My.Section"], "label": "My View", - "pathname": "/my-view" - } + "icon": "icon-add", + "pathname": "my-view" + }, + "conditions": [ + { + "alias": "Umb.Condition.SectionAlias", + "match": "My.Section", + } + ] } ``` + +{% endtab %} + +{% tab title="Typescript" %} + + +The manifest can also be written in TypeScript. + +For this typescript example we used a [Backoffice Entry Point](../../extending-overview/extension-types/backoffice-entry-point) extension to register the manifests. + +```typescript +import { ManifestSectionView } from "@umbraco-cms/backoffice/extension-registry"; + +const sectionViews: Array = [ + { + type: "sectionView", + alias: "My.SectionView", + name: "My Section View", + element: () => import('./my-section.element.ts'), + meta: { + label: "My View", + icon: "icon-add", + pathname: "my-view", + }, + conditions: [ + { + alias: 'Umb.Condition.SectionAlias', + match: 'My.Section', + } + ] + } +] +``` + + {% endtab %} + +{% endtabs %} + + +### Lit Element + +Creating the Section View Element using a Lit Element. + + +**my-section.element.ts:** +```typescript +import { UmbLitElement } from "@umbraco-cms/backoffice/lit-element"; +import { css, html, customElement, property } from '@umbraco-cms/backoffice/external/lit'; + +@customElement('my-sectionview-element') +export class MySectionViewElement extends UmbLitElement { + + render() { + return html` + + Sectionview content goes here + + ` + } + + static override styles = [ + css` + :host { + display: block; + padding: 20px; + } + `, + ]; + +} + +export default MySectionViewElement; + +declare global { + interface HTMLElementTagNameMap { + 'my-sectionview-element': MySectionViewElement; + } +} + +``` diff --git a/15/umbraco-cms/customizing/section-trees/sections/section-view.md b/15/umbraco-cms/customizing/section-trees/sections/section-view.md index d8f37c9a624..fcb3e3a3882 100644 --- a/15/umbraco-cms/customizing/section-trees/sections/section-view.md +++ b/15/umbraco-cms/customizing/section-trees/sections/section-view.md @@ -12,17 +12,100 @@ This page is a work in progress and may undergo further revisions, updates, or a

Section View

-**Manifest** +## Creating a custom Section View + +### Manifest + +**Using Json** + +We can create the manifest using json in the `umbraco-package.json`. ```json { "type": "sectionView", "alias": "My.SectionView", "name": "My Section View", + "element": "./my-section.element.js", "meta": { - "sections": ["My.Section"], "label": "My View", - "pathname": "/my-view" - } + "icon": "icon-add", + "pathname": "my-view" + }, + "conditions": [ + { + "alias": "Umb.Condition.SectionAlias", + "match": "My.Section", + } + ] } ``` + +**Using TypeScript** + +The manifest can also be written in TypeScript. + +```typescript +import { ManifestSectionView } from "@umbraco-cms/backoffice/extension-registry"; + +const sectionViews: Array = [ + { + type: "sectionView", + alias: "My.SectionView", + name: "My Section View", + element: () => import('./my-section.element.ts'), + meta: { + label: "My View", + icon: "icon-add" + pathname: "my-view", + }, + conditions: [ + { + alias: 'Umb.Condition.SectionAlias', + match: 'My.Section', + } + ] + } +] +``` + +### Lit Element + +Creating the Section View Element using a Lit Element. + + +**my-section.element.ts:** +```typescript +import { UmbLitElement } from "@umbraco-cms/backoffice/lit-element"; +import { css, html, customElement, property } from '@umbraco-cms/backoffice/external/lit'; + +@customElement('my-sectionview-element') +export class MySectionViewElement extends UmbLitElement { + + render() { + return html` + + Sectionview content goes here + + ` + } + + static override styles = [ + css` + :host { + display: block; + padding: 20px; + } + `, + ]; + +} + +export default MySectionViewElement; + +declare global { + interface HTMLElementTagNameMap { + 'my-sectionview-element': MySectionViewElement; + } +} + +``` \ No newline at end of file