Different behavior of path/url with sightly | Community
Skip to main content
New Participant
May 31, 2018
Solved

Different behavior of path/url with sightly

  • May 31, 2018
  • 3 replies
  • 5623 views

Hi, I am working with sightly in a template that has a link to redirect to the parent page, I can access the path of the parent wit this: currentPage.parent.path, this give me the complete path of the parent.

But also I need that with a extension .html in author environment (wcmmode enabled and disabled), and with a / in production.

How can I do that? Its possible with sightly or I should look a SlingModel solution?

Thank you in advance

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

if you use this solution make sure you remove wcmmode.disabled while checking author because wcmmode.disabled return true in publish environment.

so you can modify condition like <div data-sly-test.author="${wcmmode.edit || wcmmode.design  || wcmmode.preview}">

if you want to get runtime mode in HTL you can use java or JS and read wcm mode from sling model like below

@Inject

    private SlingSettingsService settings;

public Boolean getAuthorRunMode() {

    author = settings.getRunModes().contains("author");

        return author;

   }

Thanks

Arun

3 replies

arunpatidar
arunpatidarAccepted solution
New Participant
May 31, 2018

Hi,

if you use this solution make sure you remove wcmmode.disabled while checking author because wcmmode.disabled return true in publish environment.

so you can modify condition like <div data-sly-test.author="${wcmmode.edit || wcmmode.design  || wcmmode.preview}">

if you want to get runtime mode in HTL you can use java or JS and read wcm mode from sling model like below

@Inject

    private SlingSettingsService settings;

public Boolean getAuthorRunMode() {

    author = settings.getRunModes().contains("author");

        return author;

   }

Thanks

Arun

Arun Patidar
jorarteagAuthor
New Participant
May 31, 2018

Hi, yes, I already know that, but Im looking for a cleaner way, if this exists and it's worth to do.

I found this <a href="${link} @ extension = 'html'" this seems work with JcrResourceResolverFactory, but I donk know yet how this will work on the publish instance.

Thanks for your help anyway! that will be one of my possible solutions

arunpatidar
New Participant
May 31, 2018

Hi,

You can get wcmmode in sightly. based on that you can render content.

HTL introduction part 1

e.g.

<div data-sly-test.author="${wcmmode.edit || wcmmode.design || wcmmode.disabled || wcmmode.preview}">

  Show this to the author - Parent  Page -  ${currentPage.parent.path}.html

</div>

<div data-sly-test="${!author}">

  Not in author mode anymore..

</div>

Thanks

Arun

Arun Patidar