Getting current page from widget

Posted by Community Admin on 05-Aug-2018 15:32

Getting current page from widget

All Replies

Posted by Community Admin on 08-Sep-2010 00:00

I am trying to get a reference to the  Page from within a widget (it seems this should be pretty easy)


Here is some 3.7 code that I was trying to use, without much luck.

CmsManager man = new CmsManager(); 
ICmsUrlContext page = (ICmsUrlContext)this.Context.Items[UrlHelper.CmsPageKey]; 
string Id = page.PageID.ToString(); 


Posted by Community Admin on 08-Sep-2010 00:00

Hello Joe Keller,

You can get the current site map node and from it get the current page:

SiteMapNode currentNode = SiteMap.CurrentNode;
if (currentNode != null)
    var pManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager();
    Telerik.Sitefinity.Pages.Model.PageData page = pManager.GetPageData(new Guid(currentNode.Key));

All the best,
Radoslav Georgiev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Posted by Community Admin on 23-Dec-2010 00:00

Would you be perhaps able to wrap this into the PageManager or Page Facade to make it easier to grab the current page reference?

Posted by Community Admin on 24-Dec-2010 00:00

Hi Joe,

There is another way to get the current page - SiteMapBase.GetActualCurrentNode() will return the  PageSiteNode. We will consider adding a method in the fluent API that will return the ID directly.

Greetings,
Ivan Dimitrov
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Posted by Community Admin on 29-Apr-2011 00:00

Hi Radoslav,

SiteMap.CurrentNode doesn't work in 4.1. It's returning null. In 4.1 is there an alternative way to find the current page. Simply what I need is to find the URL of the current page. The logic I have implemented was based on

SiteMap

 

 

.CurrentNode.Url and it's not working anymore since the CurrentNode is returning null.

Thanks,
Duneel

Posted by Community Admin on 03-May-2011 00:00

Hi Duneel,

What about using GetActualCurrentNode as suggested?

All the best,
Ivan Dimitrov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Posted by Community Admin on 03-May-2011 00:00

Thanks Ivan! GetActualCurrentNode worked.

This thread is closed