Overview
The Location module provides utilities for managing your app’s iframe within the Shopware Administration. It handles iframe height adjustments, URL synchronization, and location identification.Location Identification
Get Current Location
Retrieve the location ID of your current iframe:Check Specific Location
Verify if your app is in a specific location:Check if Running in Iframe
Determine if your app is embedded in an iframe:How Location IDs Work
Location IDs are passed via URL parameters:Location Types
Main Module
Register a standalone module in the admin navigation:?location-id=my-custom-module.
Menu Item
Add a menu item that links to your module:Settings Page
Add a settings page:Tab in Detail Page
Add a tab to existing detail pages:Action Button
Add an action button to list views:Component Section
Render custom content in specific admin sections:Height Management
Update Height Manually
Set a specific height for your iframe:Auto-Resize Observer
Automatically adjust iframe height when content changes:body { overflow: hidden } to your CSS to prevent double scrollbars.
URL Synchronization
Update URL
Synchronize your iframe’s URL with the admin:Auto URL Updater
Automatically synchronize URL changes:Practical Examples
Vue Component with Auto-Resize
React Component with URL Sync
Conditional Rendering by Location
Dynamic Height Updates
Special Location Constant
MAIN_HIDDEN
A special location ID for hidden main modules:Message Types
The location module uses these message types:locationUpdateHeight
locationUpdateUrl
Best Practices
1. Always Use Auto-Resizer for Dynamic Content
2. Clean Up Observers
Always stop observers when components unmount:3. Prevent Double Scrollbars
Add CSS to prevent scrollbars in the iframe:4. Validate Location Context
5. Use Unique Location IDs
Ensure your location IDs are unique to avoid conflicts:Performance Considerations
- The auto-resizer uses
ResizeObserver, which is efficient for detecting size changes - The auto-URL updater polls every 50ms—consider if you need it for your use case
- Each
updateHeight()call sends a message to the parent window—avoid excessive calls - Use auto-resizer instead of manual intervals for better performance
Next Steps
- Learn about Architecture for message passing details
- Explore Context API for accessing Shopware context
- Understand Data Handling for working with entities