A Developers Blog: AEM Tutorial On Building A Sightly Page Component

This blog has moved to GitHub, and you should be redirected shortly...

Friday, April 10, 2015

AEM Tutorial On Building A Sightly Page Component

The purpose of this tutorial is to show you how to build an AEM page component using sightly. You can read more about sightly here: Sightly

For this tutorial we will be using crxde lite. This tutorial does not go into full detail, but does provide all the code that was used in the creation of this component for learning purposes.

For this tutorial I was using: AEM 6.0. You should be able to follow along with other versions of this software.

In order to follow along with this tutorial, you will need to have a basic project structure already set up, or you can follow along with this tutorial here:

Basic Project Setup Tutorial

If you have not completed the tutorial listed above, you can download a package from GitHub that has the completed project from here: AEM-Getting-Started. Just follow the instructions in the "readme" file to install the package into your instance of AEM.

If you have completed the previous steps, we can get started.

1. Once your instance of AEM is up and running, navigate to crxde lite. Navigate to the "myProject" folder, click on the "components" folder, and then click on the "page" folder.

2. Right click on this folder and choose "Create Component". Enter the following information:


Keep clicking the "Next" button until you can click the "OK" button.

3. Right click on the component you just created, and choose "Create File". Name the file: simplePageSightly.html.

4. Right click on the "simplePageSightly.jsp" file, and choose delete.

5. Now, open the "simplePageSightly.html" file, and add the following code to it:

6. Next we need to create a template for the page component. Right click on the "templates" folder, and choose "Create Template". An example is posted below:


Click the "Next" button. In the "Allowed Paths" section add the following: /content(/.*)?
Keep clicking the "Next" button until you can click the "OK" button.

7. Next go to the websites console and choose the option to create a page. Make sure to choose the "Simple Page Template - Sightly" from the template options.

8. Now open up the page you just created, and you should see your simple page component that you just created with sightly.

Summary: This tutorial showed you how to create a simple page component by using sightly. You can build upon this page by adding content to it, or by making a full site.

I hope you enjoyed this tutorial. If you have any questions or comments, please feel free to post them below.

You can download a package of the component on GitHub from here: Sightly Page Component

Labels: , ,

2 Comments:

At September 7, 2015 at 4:51 AM , Anonymous Anonymous said...

I am new to AEM.how do we use AEM SIGHTLY to populate drop down values (values will come via js file) for "SELECT" html tag

 
At September 11, 2015 at 12:47 AM , Blogger Scott Westover said...

In order to use JS, with sightly, you will want to put your JS file in a client library folder and then load that library through a sightly data-sly-call tag.

Here is an example of the calling the JS files from a client library: js data-sly-call="${clientLib.js @ categories=['category1', 'category2']}" data-sly-unwrap/

With the tag, you can then use JS like normal to populate the drop down values.

You can read more here: http://docs.adobe.com/content/docs/en/aem/6-0/develop/sightly.html#Loading Client Libraries

If you still need help, just let me know.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home