Howto Implement IHomePageProvider

Topics: Customizing Orchard
Nov 29, 2011 at 10:56 PM

I'm having a little trouble understanding the intent of some of the methods on the IHomePageProvider interface, and how to use the interface to register my own home page. I was looking at Nick's blog post here: http://www.themayneissue.com/memorystream/custom-home-page-provider-for-static-pages-in-orchard. Which seems to make sense, except I don't get how he's using the CurrentSite property in the constructor. When I tried that, the CurrentSite is null in the constructor (as I would expect it to be).

Nick, if you happen to see this, is that code on your blog post correct? Has anybody else implemented this interface and able to explain how to use it?

Thanks,
Kevin 

Nov 29, 2011 at 11:19 PM

Between Nick's post and looking at the HomeController in Core we kinda figured it out - the GetSettingValue and GetHomePageId methods weren't really needed for our purposes. We were able to get it to use our provider by manually changing the HomePage value on the CurrentSite (by directly updating the column in the SiteSettingsPartRecord table).

So that works, but how do you get it to register your provider without hacking the db table?

Dec 1, 2011 at 1:26 AM

I realized that I could set this setting in a recipe, which works perfectly for my situation. I'm still curious though if there's another method for setting a custom home page provider other than by marking an actual page as the home page.

Dec 1, 2011 at 2:01 AM

You just have to look at some of the existing code that references an IHomePageProvider. The implementation is pretty strange! I think the existing modules just grab ISiteSettings and change the HomePage setting when needed. Anyway, this will all disappear with Alias and Autoroute.