Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

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

Avatar

Avatar
Validate 1
Level 1
karthick1356
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
karthick1356
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
karthick1356
Level 1

24-03-2021

 
View Entire Topic

Avatar

Avatar
Validate 1
Level 7
KiranVedantam1992
Level 7

Likes

159 likes

Total Posts

159 posts

Correct Reply

47 solutions
Top badges earned
Validate 1
Establish
Give Back 3
Give Back
Boost 50
View profile

Avatar
Validate 1
Level 7
KiranVedantam1992
Level 7

Likes

159 likes

Total Posts

159 posts

Correct Reply

47 solutions
Top badges earned
Validate 1
Establish
Give Back 3
Give Back
Boost 50
View profile
KiranVedantam1992
Level 7

24-03-2021

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