Overview
We’ll create a video player element for Dailymotion that includes:- Element registration
- Preview component
- Configuration component
- Element rendering component
Project Structure
Complete Implementation
Step 1: Define Constants
cms/ex-dailymotion/ex-dailymotion-constants.ts
Step 2: Register the CMS Element
init/init-app.ts
Step 3: Create Preview Component
cms/ex-dailymotion/ex-dailymotion-preview.vue
Step 4: Create Configuration Component
cms/ex-dailymotion/ex-dailymotion-config.vue
Step 5: Create Element Component
cms/ex-dailymotion/ex-dailymotion-element.vue
Step 6: Register Locations
locations/init-locations.ts
Usage in CMS
Configuration Data Flow
- Config component updates data via
data.update() - Publishing key broadcasts changes
- Element component receives updates via
data.subscribe()
Creating a CMS Block
You can also register a block that uses your element:Advanced: Two-Column Video Block
Create a block with two videos side by side:Expected Output
In CMS Editor
- Element appears in sidebar with preview
- Drag-and-drop functionality works
- Configuration modal opens on click
- Live preview updates as you type
On Storefront
- Responsive video embed
- Full Dailymotion player functionality
- Proper aspect ratio maintained
Best Practices
- Use vendor prefix: Name elements uniquely (e.g.,
my-company-video) - Provide defaults: Always set default config values
- Live preview: Subscribe to config changes in element component
- Error handling: Handle missing or invalid URLs gracefully
- Responsive design: Ensure elements work on all screen sizes
- Accessibility: Add proper ARIA labels and keyboard support