Component Title | External Content |
Description | Allows authors to add third-party widgets (e.g. chatbots, lead generation forms, social media posts, social pixels, videos etc.) to a page. |
Features |
|
Location | /apps/ehi-core/aem65/components/content/external-content/v1/external-content |
sling:resourceSuperType | core/wcm/components/embed/v1/embed |
Supported AEM Versions | 6.5 |
Editing Mode | inPlaceEdit |
Component Group | Cheerios Experience |
BLOCK cmp-embed
Extending the components can be done in multiple ways depending on the needs of the brand component.
Before defining an extension:
Extension of the External Content component is possible by providing any of the following:
Use this approach if you do not have any required html markup changes or backend java changes. This will only update the title of the component, componentGroup and point to the resourceSuperType. Optionally can extend the description.
Use this approach if you need to update css classes or add data attributes and do not need to change the backend model, or potentially want to use a different model by retain all of the markup in the component-tmpl.html (Component Template) markup.
The component template is usually named component-tmpl.html this file contains the html markup. Update this file if you need to change the html structure of the component.
Use this approach if you need to change the Sling Model to update the backend logic.
Files that will need to be added when extending:
It is possible to extend more than just the component.html file, if necessary any file that is resourceSupertyped can be extend for example if something needs added to the dialog.
This gives us the flexibility to change our classes or add attributes easily. Say I want to add new javascript I can easily target a different data attribute to trigger my javascript.
By implementing the UrlProcessor interface you can create your own URL processor.
You will also need to create an HTL template file, with the same name as the processor field returned in the Result.
URLProcessor interface:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.wcm.core.components.services.embed;
import java.util.Map;
/**
* Interface that defines a generic processor for a given URL.
*
* @since com.adobe.cq.wcm.core.components.services.embed 1.0.0
*/
public interface UrlProcessor {
/**
* Returns the result of processing the given URL, {@code null} if processing is not possible or failed.
*
* @param url The URL to process
* @return The {@link Result} of processing, {@code null} if processing is not possible or failed.
* @since com.adobe.cq.wcm.core.components.services.embed 1.0.0
*/
Result process(String url);
/**
* @since com.adobe.cq.wcm.core.components.services.embed 1.0.0
*/
interface Result {
/**
* Returns the name of the processor that was able to process the URL.
*
* @return Name of the processor.
* @since com.adobe.cq.wcm.core.components.services.embed 1.0.0
*/
String getProcessor();
/**
* Returns the data from the processor that was able to process the URL.
*
* @return Data from the processor that was able to process the URL.
* @since com.adobe.cq.wcm.core.components.services.embed 1.0.0
*/
Map<String, Object> getOptions();
}
}
By adding an OSGi configuration you can embed an URL from an oEmbed provider.
YouTube Configuration:
# Copyright 2019 Adobe
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
provider="YouTube"
endpoint="https://www.youtube.com/oembed"
format="json"
scheme=["https://.*\.youtube.com/watch.*","https://.*\.youtube.com/v/.*","https://youtu\.be/.*"]
unsafeContext="true"
The following configuration properties are used:
The following JCR properties are used:
- jcr:primaryType: nt:unstructured
- jcr:createdBy: E364WW
- annotation: 1
- jcr:lastModifiedBy: E141ZP
- embeddableResourceType: ehi-core/aem65/components/content/external-content/v1/external-content/embeddable/youtube
- jcr:created:
- url: https://www.youtube.com/watch?v=crcAefP2V9M
- type: embeddable
- youtubeVideoId: rYzCJ24qJj4
- jcr:lastModified:
- sling:resourceType: ehi-core/aem65/components/content/external-content/v1/external-content
- autoPlay: 0
- closedCaption: 0