Why exactly templates are needed in CQ? - content-management-system

Why exactly do we need templates when all a template does is to have a resourceType property attached to a content-page component.
At the time of creating new page, shouldn't authors directly select that component instead?

The template nodes define the metadata for the page that will be created, one aspect of which is the underlying resource type (i.e. the Page component that will be used to render out the content).
Some example of other things configured at a template level include:
The default content that is included when the page is created. This
is stored under the template node itself, i.e. in /apps/[your-site]/templates/homepage.
For example, you could add a carouselnode underneath the homepage node, to ensure that any page created with the homepage template will have a carousel node added by default.
The allowed parents & children of the template — e.g. configuring the homepage template so that it can't be placed beneath other templates.
The allowed components in each parsys — In /etc/designs/[your-design]/jcr:content, you can defined what components can be added to a particular parsys, which applies to any page using that template.
By having a separation between templates & page components it allows us to re-use the same renderers (e.g. JSP scripts), but have aspects like these configured differently for different templates.

Related

Is it possible to have a container prepopulated with a specific component through a prototype page in Hippo CMS / brXM?

In an attempt to set up a new page with a single vbox container I'm able to get the container to show in the Channel Manager but this requires the CMS editor to add all of the individual components by hand. Alternatively we can place components directly on the page and through the configuration in the prototype but that does not allow the CMS editor to edit the component configuration (Info) or associate a document. The question is then, in an attempted compromise, is it possible to repopulate the container with a specific component so that the the CMS editor is provided a default set of components in the containers when creating a new page from a prototype/template page?
I believe the key term you are looking for is hst:prototypepages
Their documentation can be found at https://documentation.bloomreach.com/14/library/concepts/hst-configuration-model/prototypepages-configuration.html but basically you can define the prototype having certain components already on the page - and possibly even default settings for those components.
A similar concept at the component level is the hst:catalog
You can define "component prototypes" with default settings for when they are placed onto a page.

Deleting, Moving pre defined components from template in Adobe AEM

I have requirement where, in template we will have some list of components by default. But the requirement is, author can delete,move these components in the page.
We are using sightly and I have used
<div sly data-sly-resource="${'sample' # resourceType='sampleapp/components/content/sample'}" />
This is working fine. But I am not sure how do to delete and move this component.
Any help is appreciated.
If you have a template/component in which you include a specific component then it cannot be moved or deleted. It will show the delete option but after refresh it will be there again (not configured). The things that can be moved are components placed within parsyses.
To create template which has predefined components that can be then moved around you need to base your structure on parsyses. Place your predefined components within the templates parsyses - within the templates jcr:content. Remember that template is nothing else then a predefined content node.
See the example in which the survey-template has predefined content:

Can I make a simple page in CQ ?

What is the minimum that I have to do to make a content page and render it in CQ ?
Do I have to have a template ?
Does it have to be a CQ:Page type node with a supertype ?
As mentioned my "Brian",
Short Answer
See:- http://localhost:4502//apps/geometrixx-gov/templates/homepage
create a node of type cq:Page and save, add cq:PageContent node under page node, add required properties to show the component & if you want to add some default node under this cq:PageContent node add all of them manually.
Long Answer
Can we create a page without template?
in this post I will explain it's answer in detail. before knowing the answer of this question just rethink the definition of a Template.
"A template is used to create a Page and defines which components can be used within the selected scope. A template is a hierarchy of nodes that has the same structure as the page to be created, but without any actual content"
when you create a template using crxde lite then it creates two nodes by default having primaryTypes
cq:Template as parent
cq:PageContent as child
When we create a page using template via siteadmin then siteadmin uses content page component & it copies all the child nodes under the template to a newly created page node.
and once the page has been created it doesn't require cq:Template as all the child node of the template copied under cq:Page node & these nodes contains all the required properties to display a component group for that page.
It means if you want to create a page without template you can do that but it's not possible using siteadmin console as it's content page component uses templates to create pages.
you have to do all this stuff manually from crxde i.e.
create a node of type cq:Page and save, add cq:PageContent node under page node, add required properties to show the component & if you want to add some default node under this cq:PageContent node add all of them manually.
It's not a good practice to create a page manually, always use templates as it provides different set of properties which are very helpful while creating pages or websites.
Some of important properties are -
allowedTemplates
allowedPaths (deprecated Now)
allowedParents
allowedChildren
these properties can be used for filtering the page structure using siteadmin console. but if you are creating a page manually then you have to take care about all of these restriction by your own.
Source Link:- http://versatileankur.blogspot.in/2014/07/page-without-template-in-cq5.html
Another Ways:-
Use of Site Importer tool
Link:- https://docs.adobe.com/docs/en/aem/6-2/develop/dev-tools/site-importer.html
It helps in importing static website into AEM.
Creating a Website
Link:- http://www.aemcq5tutorials.com/tutorials/aem-create-a-website-in-cq5/
I hope this would help you.
Thanks and Regards
Kautuk Sahni
The absolute minimum is a node with primaryType of cq:Page (or a subtype) and a child node called jcr:content with a primaryType of cq:PageContent (or a subtype).
Of course, this will render a blank page. To render something on this page, you need to add nodes to the jcr:content node.

how properties are stored in /etc/designs for design dialog

I'm new to CQ5 and working on a project that deals with refactoring code that uses design dialogs.
Currently, I have a property declared as part of design dialog of my component. It creates a folder in /etc/designs/ for each template my component is used on. Is there a way we can make sure that those property values are stored at one particular configuration in /etc/design(as opposed to multiple)? I need to make sure only one set of configurations is used for all pages that use my component.
Thanks in advance!
Pallavi
The designs are linked to the template and not the whole site.
Hence whenever you configure the component in design mode, the values are stored within the corresponding template under the jcr:content of the configured design page or under /etc/designs/default/jcr:content in case no design is configured.
As far as I know, there is no way to tell AEM to store all the design configurations under one single path, unless you are using absolute paths in your dialog / page configurations.
If you are using multiple templates in your site, there must be one master template (which render global components eg. header/logo/navigation & footer), and all other templates should extend master template to get these global components and change pagelayout for content section.
Saying so, if templates are structured & inherited properly, you should be able to set design dialog property on home page (created using master template) and all internal pages will be able to access those design property OOB. Though child pages (created using other template) can override those design property (if needed for that template) to break inheritance.

How page activation take place for pages containing inherited component i.e components dropped in iparsys?

I have created a website structure in CQ5 WCM. I have created one template and defined few parsys and iparsys into its page level component. After this i have created one page and several more pages under it. Now my question is if make changes to the iparsys component and activate it, would all the pages inheriting it will also get activated or i need to activate all the pages individually?
Yes, all the nested pages would pick-up the change. Look at it as a "computed" reference - your page containing the original content gets replicated to the publish instance's repository, and all other pages compute their HTML based on that indirectly-referred content.
Dispatcher's cache however is another beast - make sure you're invalidating whole site's cache, rather than just the page you activated.