AEM 6.2 How to change template of a page - aem

I have created live copy of a page branch from sample website, inside my website. I was just trying to update the template so that I can create a local copy of the template used with original page and then change the UI. I can see the property with the cq:template and sling:resourceType as component name in development environment(CRXDE Lite). Can anyone suggest if we can update the property to change the template and component or if there any other way to change the template.

You can update cq:template and sling:resourceType on page/jcr:content node with corresponding new values and it would effectively change the template of page.
you might run into errors if code on new page component is expecting a different content than what is currently under your jcr:content.
ps- I dont know what your use case is but this would be very crude approach and should be avoided.

Related

How to programatically create pages in AEM with editable template

I am used to work with the pagemanager to create pages:
pageManager.create(parentPath, name, template, title, false);
This works with normal templates stored in /apps. Since Adobe recommends to use editable templates (stored in /conf), the above approach does not work: It creates the page but without the template attached to the node. Is it a bug or is there another approach how to create pages based on editable templates?
That was a stupid one, sorry for asking. Resolution: Read-rights must be given for /conf.

AEM 6.1: can't fetch component properties from page nodes

I'm new on AEM and I have an issue:
I'm working on a page named 'ancillary'
I did not create this page, I modified it where it was necessary.
In jcr:content I have page properties.
As you can see from the 1st screenshot:
pas
as
pos
new
are component properties, these should populate my page (ancillary), I'm only working on 'new'. The others are not used anymore since their components are now obsolete.
This is my component which we'll call 'newComponent':
It should be able to fetch 'new' properties (1st screenshot), since in new's sling:resourceType I set path/to/newcomponent.
When I use ${properties.mynewproperty} in newcomponent.html, it won't print the property. I can only reach pageProperties like jcr:title.
My component 'newcomponent' was created as a copy of another component, which it used to lay on the page ancillary and I swapped them. I also created a copy of the node with the oldcomponent's properties. I can see the component on the page on localhost, but I can't render the text properties.
I'm very sorry I explained this very badly, I hope someone understands and manages to help me.
You can't access your 'ancillary/jcr:content/pas' sub-nodes properties for instance. Only properties stored under your 'jcr:content' can be accesed with "${properties.myProperty}. IF you need to retrieve those sub-node properties, you'll have to use a JAVA or JS model to access it.

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.