displaying a different homepage for authenticated/unauthenticated users

Topics: Customizing Orchard
Jan 24, 2012 at 6:28 AM

Hi:

I'm  working on a website in which the customer wants a different homepage if the user is authenticated or not. is there an easy way to do this in orchard with out writing a module?

Any help apreciated.

Regards

Sean.

 

Jan 24, 2012 at 11:46 AM

Showing completely different homepage content would need a module. However you can already make Widget layers respond to authenticated/unauthenticated so maybe you could achieve the two different versions with clever use of widgets.

Jan 24, 2012 at 1:24 PM

Hi:

Ok, thank you for that, how would I look at going about replacing a page, what point of the pipeline do I need to look at intercepting?

Also how would I go about adding myself to the edit page ui?

Cheers

Sean.

From: randompete [email removed]
Sent: 24 January 2012 11:47
To: Sean Farrow
Subject: Re: displaying a different homepage for authenticated/unauthenticated users [orchard:287174]

From: randompete

Showing completely different homepage content would need a module. However you can already make Widget layers respond to authenticated/unauthenticated so maybe you could achieve the two different versions with clever use of widgets.

Jan 24, 2012 at 1:37 PM

The HomePage in Orchard up to 1.3 is managed by IHomePageProvider, but the interface is a bit strange and it's about to disappear completely in Orchard 1.4 so I'd advise against it.

However you can just create a Controller and then implement an IRouteProvider to route the home page to your controller. This is how all paths work in MVC / Orchard including the home page. So just set a route with a higher priority than the existing homepage and you're set.

From your controller you can then output whatever content as your logic, and how to do that depends what type of content it is.

The IRouteProvider for the existing homepage is in Core\HomePage\Routes.cs.

Jan 24, 2012 at 1:39 PM

Cheers, I’ll take a look. After 1.4, how are things changing for my future reference?

Cheers

Sean.

From: randompete [email removed]
Sent: 24 January 2012 13:38
To: Sean Farrow
Subject: Re: displaying a different homepage for authenticated/unauthenticated users [orchard:287174]

From: randompete

The HomePage in Orchard up to 1.3 is managed by IHomePageProvider, but the interface is a bit strange and it's about to disappear completely in Orchard 1.4 so I'd advise against it.

However you can just create a Controller and then implement an IRouteProvider to route the home page to your controller. This is how all paths work in MVC / Orchard including the home page. So just set a route with a higher priority than the existing homepage and you're set.

From your controller you can then output whatever content as your logic, and how to do that depends what type of content it is.

The IRouteProvider for the existing homepage is in Core\HomePage\Routes.cs.

Jan 24, 2012 at 2:31 PM

There will be a detailed post about the upcoming changes and how to prepare. In a nutshell, RoutePart is retiring, along with HomePage. So if you have anything that depends on either of them, you'll have problems.