내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

how to get currentPage object in javascript, as javascript file resides in clientlibs folder of the component. please give me example code snippets.

Avatar

Level 4
 
1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @karthick1356 

When you say you want currentPage object in JS which is inside your clientlib, for what purpose you need it? You will not be able to get the currentPage object in JS as the context will not be avilable on clientside and it's either available on HTL or Java which is on server side.


If you can provide the use case we can come with a concrete answer.

 

Thanks!

원본 게시물의 솔루션 보기

7 답변 개

Avatar

Community Advisor

Avatar

정확한 답변 작성자:
Community Advisor

Hi @karthick1356 

When you say you want currentPage object in JS which is inside your clientlib, for what purpose you need it? You will not be able to get the currentPage object in JS as the context will not be avilable on clientside and it's either available on HTL or Java which is on server side.


If you can provide the use case we can come with a concrete answer.

 

Thanks!

Avatar

Level 4
I was trying to get language of the page. is there any possible way to get language in the frontend?

Avatar

Community Advisor

@karthick1356 
You can get it in Backend and put it in HTL as a hidden attribute on page:
<div id="some-id" data-page-lang="${model.lang}">


Then use the value in JS:
var lang = $("#some-id").data("page-lang");

 

Hope this help!

Thanks!

Avatar

Level 4
thanks letme try. is there any way to get language other then jcr:language

Avatar

Community Advisor

Avatar

Community Advisor

Hi @karthick1356,

 

you can use Javascript USE API to get all the values you need.

 

Sample code:

use(function () {
    var Constants = {
        DESCRIPTION_PROP: "jcr:description",
        DESCRIPTION_LENGTH: 50
    };

    var title = currentPage.getNavigationTitle() || currentPage.getTitle() || currentPage.getName();
    var description = properties.get(Constants.DESCRIPTION_PROP, "").substr(0, Constants.DESCRIPTION_LENGTH);

    return {
        title: title,
        description: description
    };
});

Reference page: https://experienceleague.adobe.com/docs/experience-manager-htl/using/htl/use-api-javascript.html?lan...

 

Hope this helps.

 

Thanks,

Kiran Vedantam