We are observing problems while retrieving path from the page object [com.day.cq.wcm.api.Page]. For one particular page we are not able to fetch the shortened path.
We have developed a custom breadcrumb component and the component consumes a sling model which returns a list [java.util.list] of page objects. The component works perfectly fine in most of the pages but in certain pages the component resolves to full path instead of shortened path for a particular page. We do not suspect anything difference for that particular page's properties.
Any leads are welcome.
TIA.
Related
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.
Following is the scenario
Page A has a component in which we are reading wcmmode.edit to determine if its edit mode and we are on author instance and displaying a certain section based on sightly condition data-sly-test="${wcmmode.edit}". If this page is opened stand alone, page shows the content.
Page B uses Reference Component to reuse the content authored in Page A, path reference to Page A is stored in JCR structure of Page B
When I am opening Page B the content of Page A reference is not visible. It seems as if wcmmode.edit value is not coming as expected when using through reference.
Checked the Reference Component implementation. It internally uses sling:include to point to reference path.
When user is on author edit mode, the reference component should behave as per current mode. Is there any separate configuration for this, didn't find anything in documentation?
If you look at the code for reference.jsp, very first line is -
WCMMode mode = WCMMode.DISABLED.toRequest(request);
This sets the WCMmode as DISABLED for the request and when you include the referenced component, that what it receives thus bypassing any edit logic.
You could effectively extend the reference component and have your own logic there which preserves the wcm mode.
I have a query regarding CQ. Your reply will really make the difference to my understanding.
In other CMS like Vignette, content authors create the contents separately (not directly on the page) for ex. products details and then those contents are iterated / processed to display on the page. But in CQ, the scenario is other way round. Authors directly create the content on the page. Now if same content is needed on other page, how will that be re-used ?
Regards,
Ronak
Content can be reused across pages via Reference components. From the docs:
The Reference component lets you reference text in another part of a
CQ based website (within the current instance). The referenced
paragraph will then appear as if it was on the current page. Instead
of referencing a specific paragraph, the path can also be modified to
specify an entire [paragraph-system]...
There are some other techniques for sharing content and reference data across pages, including inheritance and "data components," described in this SO Q&A.
It seems to be quite basic problem, but I still cannot find a nice solution.
I made a component that uses a dialog property.
How could I avoid setting this property for every single page if this component is used also in template?
What I already have tried:
I set name attribute in dialog.xml to absolute path - Component stops working as standalone (dropped into parsys).
Move it to design_dialog.xml - First of all it's conceptually content, so I do not like such move, and again it doeas not make much sense for standalone versions.
Change resource path to absolute, while including in template:
<cq:include path="/content/site/somepage" resourceType="/apps/portal/components/myComponent" />
For the first look it was almost it. Instances included via parsys has it's own path, and Content for template is fetched from single resource... But where to store it, to make template code independent from pages tree structure?
Is there any other nice way to do so? or at least way to improve 3.?
To the original poster, the functionality you are looking for is now supported by Shared Component Properties in ACS AEM Commons (http://adobe-consulting-services.github.io/acs-aem-commons/features/shared-component-properties.html)
Compared to your suggested solutions:
No need for absolute property path required for SCP
Agreed these are "content" properties, so they should be stored as "content" instead of "design". SCP stores these values under the homepage node of a site, making them as genuine of content as any other piece of content.
Agreed that it is bad to have a template hard-coded to a content path of a single site, especially since this makes a multi-site implementation impossible without creating a bunch of templates. SCP does not have this problem, because each site has its own homepage under which the properties are stored.
If I understand correctly, you have a component which may work in two modes:
it may be included statically in the main page renderer via <cq:include>
it may be also dropped into some parsys.
In the first mode component should have some common configuration for all pages and in the second mode it should be configured separately per-instance. The problem is how to create such common configuration.
I think your 3rd solution is perfectly fine assuming that the component configuration is shared by all sites in your CQ instance. At some point it may be too strong assumption, eg. you may have a 3 language branches under /content/site-en, /content/site-fr and /content/site-de and you'd like to make a separate configuration for each branch.
I'd suggest following improvement to the 3rd solution: you may create the shared component under some relative path which will be the same for all pages, like /content/.../configuration/shared-component (where ... may be site1, site2 or site3). Then take first two parts of the current page path, add the /configuration/shared-component suffix and use <cq:include> to include path created in such way.
You may also take a different approach and create a common configuration page referenced by all statically included components. These components may try to find their configuration automatically (via the relative path as above) or they may have a single pathfield that references configuration page.
If you don't like these options (as they assume some site structure or they need some minimal configuration for each component), consider using HierarchyNodeInheritanceValueMap. It allows you to get property from the current resource and if there is no such property, it'll look into the same resource on ancestor pages. Using this you could configure your component just once, in the site root page and inherit configuration across the whole site.
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.