Get the URL of the page using the Sitefinity 4 Fluent API

Well, that seems like a pretty simple thing. But I'm trying to use the Sitefinity 4 Fluent API to request a page and populate the Text / NavigationUrl properties for HyperLink. The text fills perfectly - but it's hard for him to get Url from the page.

PageNode page = App.WorkWith().Page(PageId).Get(); PageLink.Text = page.Title; PageLink.NavigateUrl = page.Urls.Where<PageUrlData>(pU => pU.RedirectToDefault == false).FirstOrDefault<PageUrlData>().Url; 

The first and second lines work fine (PageLink.Text shows the page name). In the third line, I get the link "The object is not installed on an instance of the object." error ... FYI PageId is the link to the page.

Any help would be greatly appreciated.

+4
source share
1 answer

Problem detected. PageNode requires the link "Telerik.Sitefinity.Pages.Model" as a link. I had this, but later it turned out that you also need to enable "Telerik.Sitefinity.Modules.Pages".

This adds a new method for my belt, which I used below (getFullUrl):

  PageNode page = App.WorkWith().Page(PageId).Get(); PageLink.Text = page.Title; PageLink.NavigateUrl = page.GetFullUrl(); 

thanks

+8
source

All Articles