Importing a custom layout page created on a different site causes "missing callback" error and an "Undefined array key..." Warning.
The imported page layout actually shows up under "Layout overrides" instead of "Layout Pages"
Steps To Reproduce
To reproduce the behavior:
Create a layout page in Site A
In the dropbutton for "manage layout" select "export layout"
Copy the json code
Paste in in Site B's Configuration Manager > Single Import and save
Visit the Structure > Layouts UI and see the problem
Actual behavior
Layout page is imported as a non-functional Layout override, a "missing callback" error is shown, and a warning is shown.
Expected behavior
The Layout page would be imported and it would work as expected.
Additional information
I believe the issue here is that a Layout Page has TWO config files; one is the layout, and the other the layout menu item. For my example pasted above, these are:
layout.layout.shopping_cart.json
layout.menu_item.shopping_cart.json
So, you need to export/import BOTH files to Site B in order for the imported layout to actually work. The problem happens when you are unaware of this, and you only import the layout json. I assume most users will trust that the "Export layout" link in the dropbutton will give them a "working version" that can be imported in another site, but that's not the case. That only gives you one of the json files.
I really can't think what a good solution might be. I guess we could automatically generate the menu item json upon import (but this will create problems if the person has customized that menu item), or at least throw a warning explaining what's going on.
Description of the bug
Importing a custom layout page created on a different site causes "missing callback" error and an "Undefined array key..." Warning.
The imported page layout actually shows up under "Layout overrides" instead of "Layout Pages"
Steps To Reproduce
To reproduce the behavior:
Actual behavior
Layout page is imported as a non-functional Layout override, a "missing callback" error is shown, and a warning is shown.
Expected behavior
The Layout page would be imported and it would work as expected.
Additional information
I believe the issue here is that a Layout Page has TWO config files; one is the layout, and the other the layout menu item. For my example pasted above, these are:
So, you need to export/import BOTH files to Site B in order for the imported layout to actually work. The problem happens when you are unaware of this, and you only import the layout json. I assume most users will trust that the "Export layout" link in the dropbutton will give them a "working version" that can be imported in another site, but that's not the case. That only gives you one of the json files.
I really can't think what a good solution might be. I guess we could automatically generate the menu item json upon import (but this will create problems if the person has customized that menu item), or at least throw a warning explaining what's going on.