Skip to content

Instantly share code, notes, and snippets.

@buddhaCode
Last active July 22, 2021 13:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buddhaCode/b27a483d6d15aa5ea7ff30dc0de0f32c to your computer and use it in GitHub Desktop.
Save buddhaCode/b27a483d6d15aa5ea7ff30dc0de0f32c to your computer and use it in GitHub Desktop.
Shopware postMessage enabled iFrame in a tab
//{namespace name=backend/order/main}
//{block name="backend/order/view/detail/window"}
//{$smarty.block.parent}
Ext.define('Shopware.apps.Order.view.detail.Window-MyIframePostMessageApi', {
override: 'Shopware.apps.Order.view.detail.Window',
createTabPanel: function() {
var me = this, tabs;
tabs = me.callParent(arguments);
tabs.add(me.createTabWithIFrame());
return tabs;
},
createTabWithIFrame: function () {
var me = this;
return me.createPostMessageApiEnabledTabComponent(
'Mein Tab',
'{url controller=MyController action=index orderId=""}' + me.record.get('id')
);
},
createPostMessageApiEnabledTabComponent: function(label, url) {
var me = this,
swModuleManager = Shopware.ModuleManager,
// @see Shopware.ModuleManager.createSimplifiedModule()
instance = swModuleManager.uuidGenerator.generate(),
content = swModuleManager.createContentFrame(url, instance, true),
subApp = null,
windows = Ext.create('Ext.util.MixedCollection'),
contentWindow;
contentWindow = Ext.create('Ext.Component', {
title: label,
component: 'main',
content: 'content',
style: 'height: 100%',
listeners: {
render: function(component, eOpts) {
component.el.appendChild(content);
component.setLoading(true);
},
},
});
content.dom._window = contentWindow;
windows.add('main', contentWindow);
// push component into registry
swModuleManager.modules.add(instance, {
name: url,
instance: instance,
subApp: subApp,
windows: windows
});
return contentWindow;
}
});
//{/block}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment