0

I'm redesigning the templates for our online store (Using Castle Monorail with the NVelocity view engine) but want to provide the old layout to certain users.

I've started out adding a variable to the PropertyBag that determines the version the user should get and set the layout to 'BaseLayout.vm' which looks like this:

#if($StoreVersion == 2)
    #parse("VersionTwo/DefaultLayout.vm")
#else
    #parse('VersionOne/DefaultLayout.vm')
#end

This works OK for the layout and I can technically use this approach in every template file, but this seems a bit long winded. Is there a better way I can mechanize this?

Septih
  • 1,436
  • 17
  • 40
  • Is that the entire content of BaseLayout.vm or just a part of it? – Mauricio Scheffer Nov 28 '11 at 13:04
  • That's the whole file. The idea would be to have the file that represents the action just redirect to the version specific template. I'm just curious whether there's a better way to redirect to the version specific template than that. – Septih Nov 28 '11 at 14:10
  • Why not just set the `LayoutName` property in the controller? – Mauricio Scheffer Nov 29 '11 at 01:55
  • I thought I'd looked for that before, but I must have missed it. I can use that and override PreSendView in the abstract controller and that'll do the job. Thanks. – Septih Nov 30 '11 at 13:56

2 Answers2

2

Instead of having a layout that "forwards" conditionally to other layouts, you can put the condition in code and set the LayoutName property in the controller.

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
  • 1
    For anyone else interested, I did the above for layouts and overrode the Process method on the controller to change the SelectedViewName for actions. – Septih Nov 30 '11 at 15:26
0

I would crate a controller filter and override the layout name to be rendered based to your logic

theBOSS
  • 1
  • 1