This project is read-only.

Getting the current page

Topics: Writing modules
Jul 14, 2011 at 6:15 PM

I need a way to get at the current page (mainly the routepart) that a widget/part/etc is sitting there something on the WorkContext or something that I can use to get access to this?  The goal is to be able to use that to get at parts of the route, such as currentPage.As<RoutePart>().Path...

Jul 14, 2011 at 7:12 PM

Not really, for all we know, there could be none, or there could be several. Assuming you mean the one that gets rendered into the top-level Content zone (if there is one and only one), you could I suppose get something from WorkContext.Layout.Zones["Content"] and then look into that with a debugger and try to get to the contentItem in there (if there is one) and then As it into routable.

Then again, if all you're trying to get at is the path, why don't you just look at the current URL directly?

Jul 18, 2011 at 2:16 PM

My last resort was to look at the path, but I wanted to know if there was a built-in way to get it from orchard first...thanks...