How should I provide seperate layouts to different user types in NVelocity templates?

StackOverflow https://stackoverflow.com/questions/8294662

سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top