I'm doing this in my author instance.
so I have a page (/content/my-site/my-page) with sling:resourceType = "core/wcm/components/page/v3/page".
In /apps/core/wcm/components/page/v3/page, I created "page.print.html" with the following contents,
<!DOCTYPE HTML>
<html>
<head></head>
<body>
<h1>print version</h1>
</body>
</html>
When I visited localhost:4502/content/my-site/my-page.print.html, I am expecting to see "print version" in the browser. BUT it seems AEM is ignoring the "print" selector and the request is resolving to page.html instead.
Using this tool (http://localhost:4502/system/console/servletresolver), AEM can recognize my selector BUT it's just ignoring it when it renders the page.
Any ideas why this is happening? Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @jayv25585659
Create a print.html inside /apps/core/wcm/components/page/v3/page
Can you just rename your file to print.html and give it a try ?
Hey @jayv25585659 ,
It's how the sling resolution process works.
Rename your file as print.html instead of page.print.html.
Now open localhost:4502/content/my-site/my-page.print.html.
It should work now.
For above use case to work you need to access the complete path of the component authored. So in your case it may be something similar to localhost:4502/content/my-site/my-page/jcr:content/componebt-location-on-page.print.html.
but if you want the selector to work at localhost:4502/content/my-site/my-page.print.html then you need to implement your custom servlet as explained on https://taradevko.com/aem/sling-selector-best-practice/ or you can also implement sling exporter as explained on http://www.sgaemsolutions.com/2017/06/sling-model-exporter-in-aem-63.html?m=1
Hi @jayv25585659 ,
There could be several reasons why the selector is not working as expected in your AEM instance. Here are some steps you can take to debug the issue:
1. Check the Sling Mapping configuration: Ensure that there are no conflicting mappings or rules that could be overriding the selector. You can check the Sling Mapping configuration in the AEM Web Console (`http://localhost:4502/system/console/configMgr`) under the "Apache Sling Resource Resolver Factory" configuration.
2. Verify the resource type and selector: Double-check that the `sling:resourceType` property of your page is set correctly to `"core/wcm/components/page/v3/page"`. Also, confirm that you are accessing the page with the correct URL, including the selector (`/content/my-site/my-page.print.html`).
3. Check the Apache Sling Servlet Resolver: The Apache Sling Servlet Resolver is responsible for mapping requests to the appropriate servlets or scripts based on the request URL. You can use the Servlet Resolver tool (`http://localhost:4502/system/console/servletresolver`) to verify that the correct servlet or script is being resolved for your request.
4. Review the Apache Sling Resource Resolution: AEM uses Apache Sling's resource resolution mechanism to determine the appropriate resource to render for a given request. You can enable debug logging for Apache Sling Resource Resolution to get more information about how the resolution process is happening. To enable debug logging, go to the AEM Web Console (`http://localhost:4502/system/console/slinglog`) and set the log level for `org.apache.sling.resourceresolver` to `DEBUG`.
5. Clear AEM caches: Sometimes, caching can cause issues with resource resolution. Try clearing the AEM caches by going to the AEM Web Console (`http://localhost:4502/system/console/cache`) and clicking on "Clear All Caches".
By following these steps, you should be able to identify the cause of the issue and debug why the selector is not working as expected in your AEM instance.
Views
Replies
Total Likes
Hi @jayv25585659
Create a print.html inside /apps/core/wcm/components/page/v3/page
As @arunpatidar mentioned, the file is wrongly named, it should be print.html NOT page.print.html
Hope this helps
@jayv25585659 Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies