This project is read-only.

Blog Module Explanation

Topics: Core, Customizing Orchard, Writing modules
Aug 10, 2012 at 6:17 AM

Hi I'm reading the blog module in an effort to learn more about module creation.

I can't find any documentation anywhere for GetItemMetadata. I was just wondering in the BlogPartHandler.cs file what adding the route values actually does..


Also I was intrigued by the blogPathConstraint code.. I was wondering what it was used for?


Aug 17, 2012 at 9:16 PM

The ContentManager class has a GetItemMetadata method, which basically fires an event, which can be handled by any ContentHandler implementation. It gives the handlers a chance to provide / override metadata to the caller of the GetItemMetadata method.

For example, the AdminMenu class in the Contents module invokes the GetItemMetadata method (which returns a ContentItemMetadata object) and uses the "CreateRouteValues" property to determine the url to generate when rendering the "New" menu section on the dashboard.

The BlogPathConstraint is basically being used by the ArchiveConstraint class, which in turn is added as a constraint to one of the Routes (see Routes.cs). It is used in matching the correct route when a HTTP request comes in, and enables url formats like /archive/2012/08 to be matched to a certain controller action.

I haven't researched this in-depth, but this should at least give you a hint.