We will call the component as a YouTube component. When you drag and drop the component to a web page, it will display a YouTube video – specifically, a YouTube video I uploaded as a part of this learning series.
So, let us start:
- Login to CRXDELite.
- Navigate to the directory stucure we have created earlier.
- Go inside the Component folder.
- Right-click and select Create Component.
- Enter the following:
- Label: youtube
- Title: DisplayYouTube
- Description: This component is used to display the YouTube video
- Group: AEM Company
- Click Next and Next.
- Enter Allowed Parent as */parsys
- Click Next and Click OK.
- Now, rename youtube.jsp to youtube.html. (By deafault, CRXDELite creates a JSP component. I have mentioned earlier that we will create the component using Sightly. That’s why we renamed the extension to html.)
- Add the following code:
- <div style="overflow: hidden;"> <iframe width="600" height="510" src="https://www.youtube.com/embed/dI1yi2mmNuo" frameborder="0" allowfullscreen></iframe> </div>
Create a dialog now. We are not going to do anything with the dialog. However, it’s needed for a newly created component to appear in the sidekick.
Right click YouTube, select Create > Create Dialog.
Enter title as YouTube and select OK.
The component is created now. Let us enable it.
- Open the web page you created.
- Go to the Design View.
- Enable the Component Group; that is, AEM Company.
- Go to the Edit view.
- From the component group, drag and drop the component to your page.
- See the way YouTube video appears.
As usual, I have uploaded the code to my GitHub. Please feel free to use it.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.