Hi Guys,
Needed your help. I am using currentPage.getTemplate() in one of my design_dialog components for getting the Template Name (currentPage.getTemplate().getName()) and it works fine in my Author Instance.
But in Publish Instance the same component is throwing Null pointer exception. On debugging the same, i found that the currentPage.getTemplate() is returning null .
I am bit confused on this, please explain me what exactly is happening and how to get the current Page Template name in Publish Instance. Please help on this, Thanks.
Regards,
Saran
+91 9994040417
Solved! Go to Solution.
Views
Replies
Total Likes
I guess you are trying to read it as anonymous user. By default anonymous user doesn't have even read rights on template path.
So when you do currentPage.getTemplate().getName() it is going to return null all the time.
To fix this, you will need to provide read rights to anonymous user on your template path.
You can provide read rights from OSGI Console using config option available for Day CQ ACL Setup Service (com.day.cq.security.ACLSetup), put the entry like allow;jcr:read;anonymous;/apps/<project_identifier>/templates, I cannot recall if CQ restart is required, you can cross check from permissions console tab if it took new permissions for anonymous user.
You can also directly go and configure permissions for using the permissions tab.
As per me, configuring via OSGI Config is better approach as you can push those configure using config XML's.
Hope it helps.
- Runal
Views
Replies
Total Likes
I guess you are trying to read it as anonymous user. By default anonymous user doesn't have even read rights on template path.
So when you do currentPage.getTemplate().getName() it is going to return null all the time.
To fix this, you will need to provide read rights to anonymous user on your template path.
You can provide read rights from OSGI Console using config option available for Day CQ ACL Setup Service (com.day.cq.security.ACLSetup), put the entry like allow;jcr:read;anonymous;/apps/<project_identifier>/templates, I cannot recall if CQ restart is required, you can cross check from permissions console tab if it took new permissions for anonymous user.
You can also directly go and configure permissions for using the permissions tab.
As per me, configuring via OSGI Config is better approach as you can push those configure using config XML's.
Hope it helps.
- Runal
Views
Replies
Total Likes
Thanks Runal. As you suggested, on providing the Read access to Anonymous users i can able to get the values.
Thanks a lot.
Regards,
Saran
Views
Replies
Total Likes
This is a much easier way, without changing permissions:
page.getProperties().get("cq:template","")
best,
Feike
Views
Replies
Total Likes
Yes Feike. This helps. I can able to get the required output...
Thanks a lot for your help...
Regards,
Saran
Views
Replies
Total Likes
please elaborate the usage
Views
Replies
Total Likes
please elabarate as how an we get the template name
Views
Replies
Total Likes
Instead of providing read access,
We can use ${pageProperties.cq:template}
Views
Likes
Replies
Views
Likes
Replies