Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Can I use Sling selectors to pull different sightly files

Avatar

Level 3

Example: I have a component folder called file.  Underneath that folder I have two files that I would like to use to display the component: file.html and file.admin.html.  I have dropped my component onto a page and have been trying several variations on trying to get the admin version to display, so far to no avail.  Any ideas how I would get this to work (or do I need to switch over to JSP's for this component)?  Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Level 10

There is no reason why not - it's a matter of setting up your sling selectors properly. See:

https://sling.apache.org/documentation/the-sling-engine/url-decomposition.html

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

There is no reason why not - it's a matter of setting up your sling selectors properly. See:

https://sling.apache.org/documentation/the-sling-engine/url-decomposition.html

Avatar

Level 3

For what it's worth we are only on 6.0, SP1.  So I have dropped my component on to a page (its the only component within that page) within my content structure that is referenced by SMT.html.  To attempt to get the admin version of this component to show up I have tried "SMT.admin.html" and "SMT.file.admin.html".  Neither work, the just show the regular version of the component.  I did setup some logging in the code behind to show me what selectors I am using and here's what it shows:

09.06.2015 10:42:38.813 *INFO* [0:0:0:0:0:0:0:1 [1433860957354] GET /content/crown-test/en/SMT.admin.html HTTP/1.1] com.crown.web.components.content.file.File [FILE]: Resource Path: /content/crown-test/en/SMT/jcr:content/mainpar/file
09.06.2015 10:42:38.813 *INFO* [0:0:0:0:0:0:0:1 [1433860957354] GET /content/crown-test/en/SMT.admin.html HTTP/1.1] com.crown.web.components.content.file.File [FILE]: Selector String: admin
09.06.2015 10:42:38.813 *INFO* [0:0:0:0:0:0:0:1 [1433860957354] GET /content/crown-test/en/SMT.admin.html HTTP/1.1] com.crown.web.components.content.file.File [FILE]: Extension: html

AND

09.06.2015 10:45:20.406 *INFO* [0:0:0:0:0:0:0:1 [1433861120185] GET /content/crown-test/en/SMT.file.admin.html HTTP/1.1] com.crown.web.components.content.file.File [FILE]: Resource Path: /content/crown-test/en/SMT/jcr:content/mainpar/file
09.06.2015 10:45:20.406 *INFO* [0:0:0:0:0:0:0:1 [1433861120185] GET /content/crown-test/en/SMT.file.admin.html HTTP/1.1] com.crown.web.components.content.file.File [FILE]: Selector String: file.admin
09.06.2015 10:45:20.406 *INFO* [0:0:0:0:0:0:0:1 [1433861120185] GET /content/crown-test/en/SMT.file.admin.html HTTP/1.1] com.crown.web.components.content.file.File [FILE]: Extension: html

So based on what I am seeing, I think this should work.  Could someone help me out with what I am missing?