0
votes

I need to get the page path in dialog of page properties. I tried CQ.WCM.getPagePath. it works fine when page properties are changed from dialog, but returns path of siteadmin page when the dialog is accessed by right clicking on the page in site admin. Is there any other way to get page path? Thanks in advance.

1
where are you trying to access the path in the dialog? On which field and on which event??rakhi4110
I'm trying to access the path in a listener under the dialog node for beforerender event.Sharath Madappa

1 Answers

1
votes

You can get the selected path using the following code. In case the dialog is accessed from siteadmin, you can use get the selections from the active grid, or if it is accessed via the page, you can use CQ.WCM.getPagePath() method to get the path of the page.

function(comp) {
    /* if accessed via siteadmin */
    if(CQ.wcm.SiteAdmin.hasListSelection()) {
        var grid = CQ.wcm.SiteAdmin.getActiveGrid();
        var selections = grid.getSelectionModel().getSelections();

        /*Since you can view only properties of one page at a time, 
          we would be having only one item in the array */
        console.log(selections[0].id);
    } else { /* accessed via page */
        console.log(CQ.WCM.getPagePath());
    }
}

The above function can be used for the beforerender event of your dialog.