This project is read-only.

Determine I'm on a 'homepage' in .cshtml for a ContentType

Topics: Customizing Orchard, Writing themes
Nov 15, 2011 at 4:48 AM

I'd like a content type to display slightly differently depending on where it I'm inside the cshtml for that content type in my theme....

I'd like to be able to resize based on whether it's a widget or in the content area or display differently when it's part of the homepage vs regular pages

I understand there is a ton of information available for use to perform decision login within the cshtml page however I haven't come across the documentation to help me with this part.

What would the code look like and is there health documentation on what common items are programmatically available to me within the cshtml files?


Nov 15, 2011 at 2:30 PM
Edited Nov 15, 2011 at 2:30 PM

One option is to use the Theme Switcher (in Vandelay Industries module) - you can switch to different themes based on Url and other rules, or write your own rules. A theme can have a BasedOn property, so your base theme has a standard set of templates, and you can override just the templates you want to in derived themes.

There are other options like using to specify alternate template filenames based on content type or Url. Personally I recommend overriding templates based on Content Type if you can, this gives you the most ease and flexibility, and won't mess things up if you, for instance, change the Url of a page but want it to keep the same look.