This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
Is there any way I can detect if a component is being edited in touch or classic UI from the handlebar template of the component?
Thanks for reading.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi
As mentioned by Lokesh (cf# for classic and editor.html for touchUI. However this may not work if the URL changes in future), we can know if we are in Touch UI or in classic UI.
Here is a article showing use of function calling in Handlerbars.js
//
Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/communities/scf/handlebars-helpers.html
Handlebars.js Basic Overview
A quick overview of helper functions from Handlebars.js documentation :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Handlebars.registerHelper( 'link_to' , function (title, options) { return new Handlebars.SafeString( '<a href="https://forums.adobe.com/posts' + this .url + '">' + title + "!</a>" ); }); var context = {posts: [ {url: "/hello-world" , body: "Hello World!" } ] }; // when link_to is called, posts is the current context var source = '<ul>{{#posts}}<li>{{{link_to "Post"}}}</li>{{/posts}}</ul>' var template = Handlebars.compile(source); template(context); |
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
You can just have a JS function to detect it from the URL
cf# for classic and editor.html for touchUI. However this may not work if the URL changes in future
Views
Replies
Total Likes
Hi Santiago Del,
I don't think you can determine whether the author is in classic OR Touch UI in handlebar template. Because handlebar template is just a static block/section.
In order to achieve this, You have to have a conditional statement in the handlebar template and while compiling this template and passing the rest of arguments to replace all placeholders, pass one more argument (isTouchUI).
{{#if isTouchUI}}author is using TOUGCH UI{{else if} }author is in classic UI{{/if}}
Jitendra
Santiago Del Valle wrote...
Is there any way I can detect if a component is being edited in touch or classic UI from the handlebar template of the component?
Thanks for reading.
Views
Replies
Total Likes
Hi
As mentioned by Lokesh (cf# for classic and editor.html for touchUI. However this may not work if the URL changes in future), we can know if we are in Touch UI or in classic UI.
Here is a article showing use of function calling in Handlerbars.js
//
Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/communities/scf/handlebars-helpers.html
Handlebars.js Basic Overview
A quick overview of helper functions from Handlebars.js documentation :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Handlebars.registerHelper( 'link_to' , function (title, options) { return new Handlebars.SafeString( '<a href="https://forums.adobe.com/posts' + this .url + '">' + title + "!</a>" ); }); var context = {posts: [ {url: "/hello-world" , body: "Hello World!" } ] }; // when link_to is called, posts is the current context var source = '<ul>{{#posts}}<li>{{{link_to "Post"}}}</li>{{/posts}}</ul>' var template = Handlebars.compile(source); template(context); |
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Views
Like
Replies