Hi All,
Suppose I have a default component /path/to/menu, and I like to add a selector to it if it meets a condition, can I do this?
// - page is a sling model defined above
<sly data-sly-resource="${@ resourceType='/path/to/menu', data-sly-test=page.collapsedMenu? selectors='collapsed':selectors=''}"></sly>
If not, what would be a possible way doing this within HTL?
Thanks!
-kt
Solved! Go to Solution.
Views
Replies
Total Likes
I believe to call a component or service based on selector the selector should be part of request url and not with htl. If your component has selector.htl it will automatically get called but in this case you need to call the component selector via page jcr:content component path
I believe to call a component or service based on selector the selector should be part of request url and not with htl. If your component has selector.htl it will automatically get called but in this case you need to call the component selector via page jcr:content component path
Hello @kevingtan,
Yes, this is possible. You can call the conditional selectors this way ->
<sly data-sly-resource="${@ resourceType='/path/to/menu', selectors=page.collapsedMenu ? 'collapsed' : '' }"></sly>