Reputation: 735
I have a path and want to adapt it into Page using Sightly.
The user can enter a path in the dialog —
in my logic, I am using currentPage
as a default value, but if the user enters a path, I want to use this instead.
How can I change the path into a Page
object in JavaScript, in order to use all functions of the Page API? (i.e. I'm using JavaScript for my backing logic rather than Java)
Upvotes: 1
Views: 811
Reputation: 6764
The PageManager is implicitly available as a pre-defined object in the JavaScript Use-API (pageManager
), that you can go ahead & use.
E.g, if you had a variable path
, and wanted to resolve the relevant page & return its title, you could do:
use(function () {
var path ="/content/foo/bar";
return {
pageTitle: pageManager.getPage(path).title
};
});
Upvotes: 2