diff --git a/guides/plugins/apps/administration/add-cms-element-via-admin-sdk.md b/guides/plugins/apps/administration/add-cms-element-via-admin-sdk.md index e56b65e5b..8f1e4d695 100644 --- a/guides/plugins/apps/administration/add-cms-element-via-admin-sdk.md +++ b/guides/plugins/apps/administration/add-cms-element-via-admin-sdk.md @@ -52,11 +52,12 @@ When our extension is finished, you will get the following file structure: Everything starts in the `main.ts` file: ```javascript +// Prior to 6.7 import 'regenerator-runtime/runtime'; import { location } from '@shopware-ag/meteor-admin-sdk'; // Only execute extensionSDK commands when -// it is inside a iFrame (only needed for plugins) +// it is inside an iFrame if (location.isIframe()) { if (location.is(location.MAIN_HIDDEN)) { // Execute the base commands @@ -68,11 +69,23 @@ if (location.isIframe()) { } ``` -This is the main file, which is executed first and functions as the entry point. +```javascript +// 6.7 and above (inside meteor-app folder) +import 'regenerator-runtime/runtime'; +import { location } from '@shopware-ag/meteor-admin-sdk'; -Start with `if(location.isIframe())` to make sure only content used inside iFrames is loaded. While the SDK is used in apps and plugins, this check ensures the code is executed in the right place. +if (location.is(location.MAIN_HIDDEN)) { + // Execute the base commands + import('./base/mainCommands'); +} else { + // Render different views + import('./viewRenderer'); +} +``` + +This is the main file, which is executed first and functions as the entry point. -Next you need `if(location.is(location.MAIN_HIDDEN))` to **load the main commands**, which are defined in the `mainCommands.ts` file. This will only be used to load logic, but not templates into the Administration. +Use `if(location.is(location.MAIN_HIDDEN))` to **load the main commands**, which are defined in the `mainCommands.ts` file. This will only be used to load logic, but not templates into the Administration. Lastly, the `else` case will be responsible for specific loading of views via `viewRenderer.ts`. This is where the view templates will be loaded.