Get the Page Title in Component Dialog | Community
Skip to main content
Level 3
Feb 6, 2020 6:24 AM UTC
Solved

Get the Page Title in Component Dialog

I have a requirement where I want to populate the page title in the component dialog as a value.  I know this can be done by writing dialog listener, Is there any other way to do this?

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Feb 18, 2020 12:16 PM UTC

You need to write a clientlib js, below code will work and return json response of page properties and you will get the jcr:title from responseText.

 

$.get(Granite.author.page.path+".1.json")

Arun Patidar

3 replies

arunpatidar
arunpatidarAccepted solution
New Participant
Feb 18, 2020 12:16 PM UTC

You need to write a clientlib js, below code will work and return json response of page properties and you will get the jcr:title from responseText.

 

$.get(Granite.author.page.path+".1.json")

Translate
Arun Patidar
Vijayalakshmi_S
Level 10
Feb 6, 2020 10:30 PM UTC

HI, 

My previous comment is with respect to Touch UI dialog.

Translate
Vijayalakshmi_S
Level 10
Feb 6, 2020 10:27 PM UTC

HI, 

 

We can make use of dialog-ready event to manipulate dialog fields when we open a dialog.

However the use case of populating it with page title will not be possible as the same is not accessible in front end.  

Perhaps we can make use of window.location.pathname to get pagename alone by string manipulations. (If page name is framed automatically or if it is consistent across projects, you can arrive at way of making extracted page name as Page title,  again via String manipulations)

 

$(document).on("dialog-ready", function() {

       var pageTitle = ..

      $("input[name='./text']").val(pageTitle);  // name attribute of desired dialog field

});

Translate