My problem:
I have website where i have multiple designs, which administrator can switch between.
i have been wondering how to implement this into mvc2 project.
How i have done this in PHP was: create rendered content and replace holder eg: {SITE:HEADER_CONTENT}
after i had class that rendered result and passed it to the user such as $Website->Template->Render();
I have been 开发者_运维百科wondering how to do this in in asp.net mvc2 (i cannot use mvc3 as project is almost done with one template)
Any guideance will be welcomed,
P
You can achieve the same using asp.net placeholders for your content by creating placeholders for headcontent, maincontent, etc in your master page and then filling these in your content pages.
I'm not 100% sure how you'd switch between the templates, maybe by having the master passed through in viewdata from the controller? I've never tried to do that so not sure of the best solution.
You can switch between css files you declare on your master page. That will work for simple changes such as colors and backgrounds.
If you want to move elements around (i.e. one design is two-column while the other is three-column) then you need to look at http://haacked.com/archive/2009/04/22/scripted-db-views.aspx
Instead i will be using controllers for content menu controller template controller and so on.
In template controller i will be using template name for contstructor ie user will be able to specify template from template folder that will be parsed to html. and parse the code into it
精彩评论