May 19, 2020
Estimated Post Reading Time ~

Project structure in CQ5 and its Importance

The structure of the project is very important in cq5 as the software allows overriding of the base(foundation) functionalities easily by replicating the structure inside your project.

The commonly used structure is as shown in the below diagram


These are some of the folders present in the root of the CQ's tree.

The libs folder as the name says is the library folder of the software. It contains the code for most of CQ's functionality; most important from a developer's point of view among the folders is the FOUNDATION folder.

The foundation folder contains all the OOTB components and is often used by developers to extend the components.

The etc folder holds the designs, the common 'CSS' and design level configurations go into this folder.

The apps folder contains all the projects. The subfolders of a project are structured as shown inside the apps rectangle [/apps/your project/components, install, and so on].

template-->holds the templates of the website
components-->this folder holds all the custom components you make. It often contains subfolders like the page, global, common, etc.. The convention is to put components that render your templates into the page folders. the ones you use throughout the site globally. You can go on to create separate folders for particular sections of your website for better organization.
src-->The OSGI bundles(java classes for back end functionality)are created in this folder.
install-->The compiled classes of the bundles in src get stored in this folder.

The content folder contains the pages you make for the website using the templates. All the data in the components you add to the page are stored under the page's node in the content folder.

The names of folder and structure are critical in cq5 because when you want to override a specific part of the library with this set up all you do is create the exact same structure within your app folder of apps. Copy the library folder and modify it to suit your situation. The cq software will give this definition more priority and override the library definitions within that project.

This can be carried out multiple times within a project, the innermost definition will override others; similar to function overriding of OOPS allowing you to modify default behavior for each section of your website.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.