This project is read-only.

Template Selector

Topics: General, Writing modules, Writing themes
Mar 10, 2015 at 6:46 PM
I was hoping to hear some peoples thoughts on this before I dive in and build something retarded.

Simply put, I want to create a screen in the admin where the administrator can select the template that will be used in several of our pages. These are basically just several alternates for Content and part views that change the layout of the content slightly. There will be upwards of 20 of these. I can think of there are several options:
  • Use the new Layouts module
  • Use alternates
  • Create a theme for each of the templates
  • Store templates in the Database using Orchard.Templates
Are there any other options I have missed?

I'm reluctant to use the layouts module because (prepare for a convoluted explanation that will make no sense...) I don't really want the user to be worrying about designing their pages, they should just chuck their details in and it should look pretty. I'd also have to rework our system because we basically run events from Orchard and depending on the status of the event we display a different page, each with their own layout. So I guess I'd have to have each event status as different content items within the overarching event content item to make use of the layout editor.

If I were to create alternates I can imagine there will be quite a few of them (100?), does anyone know what kind of impact this might have on performance?

Would having 30 additional themes impact performance? I already have 19~ themes in our deployment...

Also, I'm not really sure how best to test performance for these questions, does anyone have any tips? I remember seeing the Glimpse integration demo'd a while back but haven't really heard anything since...

Would be great to hear, I dunno, something ^_^
Mar 10, 2015 at 7:05 PM
Hmm I was hoping that I could just "enable" a theme without setting it as current and also have its views rendered but that doesn't work without BasedOn, which I don't want to be using because I have a lot of different themes that handle the rest of the sites styling etc.
Mar 10, 2015 at 9:59 PM
Sounds like you're looking for something like the LayoutSelector module. It essentially provides you with a LayoutSelectorPart that lets you pick one of the available layouts (enumerated bases on a naming convention I believe, e.g. all razor files starting with "Layout-") and adds the selected layout as an alternate to the Layout shape, causing the selected layout to be used for rendering.