Hi,
I want to check publish mode & edit mode in the HTL. Example: in the Article component article.html I want to check if "publish mode" print "ABC", If "edit mode" print "XYZ"
How to do that?
Thanks & Best regards,
BienHV
Solved! Go to Solution.
Hi,
You can do it by using following lines of code
<sly data-sly-test="${wcmmode.edit}">
<h4>XYZ</h4>
</sly>
<sly data-sly-test="${wcmmode.disabled}">
<h4>ABC</h4>
</sly>
OR
<sly data-sly-test.author="${wcmmode.edit || wcmmode.design }">
<h4>XYZ</h4>
</sly>
<sly data-sly-test="${!author}">
<h4>ABC</h4>
</sly>
For deeper knowledge on HTL block statements refer to following link;
We hope this information helps!
Regards,
Views
Replies
Total Likes
Hi,
You can do it by using following lines of code
<sly data-sly-test="${wcmmode.edit}">
<h4>XYZ</h4>
</sly>
<sly data-sly-test="${wcmmode.disabled}">
<h4>ABC</h4>
</sly>
OR
<sly data-sly-test.author="${wcmmode.edit || wcmmode.design }">
<h4>XYZ</h4>
</sly>
<sly data-sly-test="${!author}">
<h4>ABC</h4>
</sly>
For deeper knowledge on HTL block statements refer to following link;
We hope this information helps!
Regards,
Views
Replies
Total Likes
Views
Replies
Total Likes
<sly data-sly-test.author="${wcmmode.edit || wcmmode.design}"/>
<sly data-sly-test="${!author}">
on publish
</sly>
<sly data-sly-test="${author}">
on author
</sly>
Views
Replies
Total Likes
Thank you for your help.
I know that solutions. Do you have other solution? Does AEM have publish mode?
Views
Replies
Total Likes
yes,
you need to use below js to get runmode:
Read AEM runmodes from Sightly · GitHub (here you can find it in detail)
Lets say it runmode.js
var SlingSettingsService = Packages.org.apache.sling.settings.SlingSettingsService;
use(function () {
// Get runmodes and transform them into an object that is easier to read for Sightly
var runmodesObj = {};
var runmodesSet = sling.getService(SlingSettingsService).getRunModes();
var iterator = runmodesSet.iterator();
while (iterator.hasNext()) {
runmodesObj[iterator.next()] = true;
}
return {
runmodes: runmodesObj
}
});
HTL part
<sly data-sly-use.logic="runmode.js">
<p>Current runmodes: ${logic.runmodes}</p>// it will gives you all runmodes like
Current runmodes: crx3,author,samplecontent,crx3tar
<sly data-sly-test="${logic.runmodes.author}">
in author
</sly>
<sly data-sly-test="${logic.runmodes.publish}">
in publish
</sly>
Views
Replies
Total Likes
Thank you so much,
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies