Skip to content

Commit c672eb3

Browse files
committed
menu: updated v15 to match v14
1 parent 80233be commit c672eb3

File tree

1 file changed

+65
-17
lines changed
  • 15/umbraco-cms/customizing/extending-overview/extension-types

1 file changed

+65
-17
lines changed

15/umbraco-cms/customizing/extending-overview/extension-types/menu.md

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,35 @@ This page is a work in progress and may undergo further revisions, updates, or a
66

77
<figure><img src="../../../.gitbook/assets/menu.png" alt="" width="250"><figcaption><p>Menu</p></figcaption></figure>
88

9-
**JSON Manifest:**
9+
## Creating a custom menu
10+
11+
In this section, you can learn how to register and create a custom Menu for the Umbraco backoffice.
12+
13+
### Manifest
14+
15+
The manifest file can be created using either JSON or Typescript. Both methods are shown below.
16+
17+
{% tabs %}
18+
19+
{% tab title="Json" %}
20+
21+
We can create the manifest using json in the umbraco-package.json.
22+
1023
```json
1124
{
1225
"type": "menu",
1326
"alias": "My.Menu",
1427
"name": "My Menu"
1528
}
1629
```
30+
{% endtab %}
31+
32+
{% tab title="Typescript" %}
33+
34+
The manifest can also be written in TypeScript.
35+
36+
For this typescript example we used a [Backoffice Entry Point](../../extending-overview/extension-types/backoffice-entry-point) extension to register the manifests
1737

18-
**Typescript Manifest:**
1938
```typescript
2039
import { ManifestMenu } from "@umbraco-cms/backoffice/extension-registry";
2140

@@ -28,18 +47,31 @@ const menuManifest: Array<ManifestMenu> = [
2847
];
2948
```
3049

50+
{% endtab %}
3151

32-
## Menu Item <a href="#menu-item" id="menu-item"></a>
52+
{% endtabs %}
3353

34-
<figure><img src="../../../.gitbook/assets/menu-item.png" alt="" width="250"><figcaption><p>Menu Item</p></figcaption></figure>
54+
# Menu Item
3555

36-
### What is a Menu Item?
56+
<figure><img src="../../../.gitbook/assets/menu-item.png" alt="" width="250"><figcaption><p>Menu Item</p></figcaption></figure>
3757

3858
Menu items are the items that appear in the menu.
3959

40-
For adding custom menu items we can define a single MenuItem manifest and link an element to it. In this element we can fetch the data and render as many menu items as we want based on that data.
60+
## Creating a custom menu items
61+
62+
In this section, you can learn how to add custom Menu Items to your Umbraco backoffice Menu.
4163

42-
### JSON Manifest
64+
### Manifest
65+
66+
To add custom menu items, you can define a single MenuItem manifest and link an element to it. In this element, you can fetch the data and render as many menu items as you want based on that data.
67+
68+
The code snippets below show how to declare a new menu item using JSON or Typescript.
69+
70+
{% tabs %}
71+
72+
{% tab title="Json" %}
73+
74+
We can create the manifest using json in the umbraco-package.json.
4375

4476
```json
4577
{
@@ -54,7 +86,15 @@ For adding custom menu items we can define a single MenuItem manifest and link a
5486
}
5587
```
5688

57-
### Typescript Manifest
89+
{% endtab %}
90+
91+
{% tab title="Typescript" %}
92+
93+
The manifest can also be written in TypeScript.
94+
95+
For this typescript example we used a [Backoffice Entry Point](../../extending-overview/extension-types/backoffice-entry-point) extension to register the manifests
96+
97+
{% code title="manifest.ts" overflow="wrap" lineNumbers="true" %}
5898
```typescript
5999
const menuItemManifest: Array<ManifestMenuItem> = [
60100
{
@@ -69,14 +109,20 @@ const menuItemManifest: Array<ManifestMenuItem> = [
69109
}
70110
];
71111
```
112+
{% endcode %}
113+
72114

73-
### The Lit Element
115+
{% endtab %}
116+
117+
{% endtabs %}
118+
119+
### The UI Element
74120

75121
#### Rendering menu items with Umbraco's UI menu item component
76122

77-
To render your menu items in Umbraco, you can make use of the powerful [Umbraco UI Menu Item component](https://uui.umbraco.com/?path=/docs/uui-menu-item--docs). This component allows you to easily create nested menu structures with just a few lines of code.
123+
To render your menu items in Umbraco, you can use the [Umbraco UI Menu Item component](https://uui.umbraco.com/?path=/docs/uui-menu-item--docs). This component allows you to create nested menu structures with a few lines of code.
78124

79-
To display the caret icon indicating nested items, you can set the `has-children` attribute dynamically like this: `?has-children=${bool}`.
125+
By default, you can set the `has-children` attribute to display the caret icon indicating nested items. It will look like this: `?has-children=${bool}`.
80126

81127
**Example:**
82128

@@ -89,9 +135,9 @@ To display the caret icon indicating nested items, you can set the `has-children
89135

90136
#### Custom menu item element example
91137

92-
Using this Lit element we can fetch the data and render the menu items. By putting the result of the fetch in a `@state()`, we can trigger a re-render of the component when the data is fetched.
138+
You can fetch the data and render the menu items using the Lit element above. By putting the result of the fetch in a `@state()`, we can trigger a re-render of the component when the data is fetched.
93139

94-
**menu-items.ts:**
140+
{% code title="menu-items.ts" overflow="wrap" lineNumbers="true" %}
95141
```typescript
96142
import { UmbMenuItemElement } from '@umbraco-cms/backoffice/extension-registry';
97143
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
@@ -167,10 +213,12 @@ declare global {
167213
}
168214

169215
```
216+
{% endcode %}
217+
170218

171-
## **Tree Menu Item**
219+
## Tree Menu Item
172220

173-
### **Manifest**
221+
### Manifest
174222

175223
```typescript
176224
// it will be something like this
@@ -186,14 +234,14 @@ declare global {
186234
}
187235
```
188236

189-
#### **Default Element**
237+
#### Default Element
190238

191239
```typescript
192240
// get interface
193241
interface UmbTreeMenuItemElement {}
194242
```
195243

196-
### **Adding menu items to an existing menu**
244+
### Adding menu items to an existing menu
197245

198246
The backoffice comes with a couple of menus.
199247

0 commit comments

Comments
 (0)