Adding a View to a specific page

Topics: Customizing Orchard, General
Jul 11, 2012 at 11:24 PM

I'm wanting to add a specific view to the home page. I know I can add a view to every page with the following:

WorkContext.Layout.Header.Add(New.User(), "1"); // Login and dashboard links

How would I modify this to only show on the home page or a specific page?

I think creating a new widget seems excessive.

Is there a way to check the layer in the view?

I'm thinking of wrapping a if around the content i.e

@if(HomePage) {


Jul 12, 2012 at 5:29 PM

Why do you think adding a widget seems excessive? This is exactly what widgets are for.

Jul 12, 2012 at 5:51 PM

Take a look at the Request property that's available in views. Based on its content, you can filter on pages.

Jul 13, 2012 at 12:08 AM

@bertrand your right I should just create a widget I was just being lazy as i didn't want to create all the code that goes with a widget when the view itself contains all the required logic.