I have a situation where a class I have is passed a PublishingPage instance and I want to enumerate any and all web part zones that are used in the Layout Page for this page.
This is proving tough.
PublishingPage has a property called Layout, which is of type PageLayout. This is different from PublishingLayoutPage which inherits (eventually) to Page which has the Zones property. This PageLayout type does not have any reference to the normal ASP.NET Page type which has the Zones property I need.
I can get an SPListItem and a SPFile from the PublishingPage.Layout property, and get the contents of the page layout in raw text form, but this can't be parsed with XmlReader as it's not valid XML (has <% tags which are invalid).
I can get an SPWeb from PublishingPage.ListItem.Web, and this can get me an SPLimitedWebPartManager, where I can get a collection of LimitedWebParts (which has Zone information) - but this won't help because at this stage of my code I have no web parts.
I'm pretty stuck, it looks like the Publishing Infrastructure is quite detached from both ASP.NET and SharePoint.
I can use the SPLimitedWebPartManager to add a dummy web part (like a new ContentEditorWebPart) to a web part zone (I have the names of the zones that are used), but when I save this out and check the page back in (and get a new SPLWPM), I can get the WebParts back but the Zone property is null (the ZoneID property is populated and correct).