-
Notifications
You must be signed in to change notification settings - Fork 811
Extension registry #7441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension registry #7441
Changes from 5 commits
ee96a26
a161af8
a30284b
ec25f59
dab9fa9
b3e303d
c747a99
b62c89a
dcb707a
8fd0c0f
16bb839
f21f543
65891de
2fae8ed
7bc234c
6b90f55
5afc948
7d7d0dd
4e94f22
1b1ca4d
6bcd917
a9f2cdb
ce6a3d9
504c166
c7953e0
0148e1c
f742741
99abb61
f63a260
a72fa7c
38be4e9
0af7332
ddcd2dc
54e8a1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
--- | ||
description: >- | ||
Bringing new UI or additional features to the Backoffice is done by | ||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
registering an Extension via an Extension Manifest. | ||
--- | ||
|
||
|
||
# Register Extensions | ||
Whether you are looking to make extensions in the context of an Umbraco project or a package, you always need a specific JSON file for this: the umbraco-package.json file. This is the starting point for any extension. | ||
Check warning on line 9 in 16/umbraco-cms/customizing/extending-overview/extension-registry/register-extensions.md
|
||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Umbraco-package.json | ||
To get extensions registered in Umbraco, you need to have an `umbraco-package.json` file. This file must be located in or in a subfolder of either the `App_Plugins` folder or the `wwwroot` folder. It's recommended to place the file in `App_Plugins/#YOUR_EXTENSION_NAME#/umbraco-package.json`, or in `wwwroot/App_Plugins/#YOUR_EXTENSION_NAME#/umbraco-package.json` for packages and Razor Class Libraries. Umbraco scans for these files on boot and reads the [`Extension Manifests`](extension-manifest.md) that are present in the file to register the extensions. | ||
Luuk1983 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{% hint style="info" %} | ||
Check warning on line 14 in 16/umbraco-cms/customizing/extending-overview/extension-registry/register-extensions.md
|
||
Even though the file is called umbraco-package.json and even though it will be displayed in the 'installed packages' overview in the backoffice, it does not mean that extensions can only work in the context of a package. | ||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
{% endhint %} | ||
|
||
{% code title="umbraco-package.json" %} | ||
```json | ||
{ | ||
"name": "My Customizations", | ||
"extensions": [ | ||
{ | ||
"type": "...", | ||
"alias": "my.customization.extension1", | ||
"name": "My customization extension 1" | ||
... | ||
}, | ||
... | ||
] | ||
} | ||
``` | ||
{% endcode %} | ||
|
||
|
||
When writing the Umbraco Package Manifest, you can use the JSON Schema located in the root of your Umbraco project. The file is called `umbraco-package-schema.json`. | ||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
{% code title="umbraco-package.json" %} | ||
```json | ||
{ | ||
"$schema": "../../umbraco-package-schema.json", | ||
"name": "My Customizations", | ||
"extensions": [ | ||
... | ||
] | ||
} | ||
``` | ||
{% endcode %} | ||
|
||
|
||
There are two additional, optional properties that can be useful: | ||
|
||
* `id` - a unique identifier of the package. If you are creating a NuGet package, use that as the id. | ||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
* `version` - the version of the package that is displayed in the backoffice in the overview of installed packages. This is also used for package migrations. | ||
|
||
|
||
This is an example of a full umbraco-package.json that registers two localization extensions: | ||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```json | ||
{ | ||
"$schema": "../../umbraco-package-schema.json", | ||
"id": "MyCustomizations", | ||
"name": "My Customizations", | ||
"version": "16.0.0", | ||
"extensions": [ | ||
{ | ||
"type": "localization", | ||
"alias": "MyCustomizations.Localize.EnUS", | ||
"name": "English", | ||
"meta": { | ||
"culture": "en" | ||
}, | ||
"js": "/App_Plugins/MyCustomizations/localization/en.js" | ||
}, | ||
{ | ||
"type": "localization", | ||
"alias": "MyCustomizations.Localize.NlNl", | ||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"name": "Danish", | ||
"meta": { | ||
"culture": "dk" | ||
}, | ||
"js": "/App_Plugins/MyCustomizations/localization/dk.js" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
|
||
## Advanced Registration | ||
### The Bundle Approach | ||
Instead of registering each manifest in the `umbraco-package.json`, you can have multiple manifests and build them into a bundle. You then register this bundle in a single `bundle` extension. In larger projects with a lot of extensions, this allows you to keep your umbraco-package.json file leaner. Read more in the [bundle approach](../extension-types/bundle.md). | ||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### The Entry Point Approach | ||
The Entry Point is an extension that executes a method on startup. You can use this for different tasks, such as performing initial configuration and registering other Extension Manifests. Read more in [the entry point approach](../extension-types/backoffice-entry-point.md). | ||
|
||
### Registration with JavaScript on the Fly | ||
In some cases, extensions are not static and cannot be registered in the umbraco-package.json or in a bundle. For instance, your manifest might be defined based on information from the server, or you might generate the manifests server side based on data in the database. In that case, you need to register extensions on the fly. | ||
Check warning on line 97 in 16/umbraco-cms/customizing/extending-overview/extension-registry/register-extensions.md
|
||
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Luuk1983 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
The following example shows how to register an Extension Manifest via JavaScript/TypeScript code: | ||
|
||
```typescript | ||
|
||
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
const manifest = { | ||
type: '...', | ||
// ... | ||
}; | ||
|
||
umbExtensionsRegistry.register(manifest); | ||
``` | ||
|
||
|
||
When and where you execute this code depends on your situation. In many cases, it makes sense to execute this on boot, using the [entry point approach](../extension-types/backoffice-entry-point.md). |
Uh oh!
There was an error while loading. Please reload this page.